@savaryna/git-add-account 1.0.3 → 2.0.1
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 +64 -56
- package/helpers/file.js +7 -7
- package/helpers/prompts.js +101 -2
- package/index.js +57 -120
- package/package.json +4 -1
- package/.github/dependabot.yml +0 -19
- package/.github/workflows/publish-package.yml +0 -21
- package/.prettierrc.json +0 -20
package/README.md
CHANGED
|
@@ -1,81 +1,88 @@
|
|
|
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 based on the workspace (directory) you are in.
|
|
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/subdirectory)_ you are in.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
Run the command direcly
|
|
7
|
+
Run the command direcly with
|
|
8
|
+
|
|
8
9
|
```shell
|
|
9
10
|
npx @savaryna/git-add-account
|
|
10
11
|
```
|
|
11
12
|
|
|
12
|
-
or if you want
|
|
13
|
+
or if you want, first install it globally
|
|
13
14
|
|
|
14
15
|
```shell
|
|
15
16
|
npm i -g @savaryna/git-add-account
|
|
17
|
+
```
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
git-add-account
|
|
19
|
+
then you can run it using
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
```shell
|
|
22
|
+
git-add-account
|
|
22
23
|
```
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
or
|
|
25
26
|
|
|
26
27
|
```shell
|
|
27
|
-
|
|
28
|
-
✔ Email to use for this account: … example@email.com
|
|
29
|
-
✔ Workspace to use for this account: … /Users/savaryna/code/email
|
|
30
|
-
✔ Name to use for SSH keys: … email_example_name
|
|
31
|
-
Enter passphrase (empty for no passphrase):
|
|
32
|
-
Enter same passphrase again:
|
|
33
|
-
✔ Do you want to sign your work? … no / yes
|
|
34
|
-
|
|
35
|
-
Your public SSH key is: ssh-ed25519 AAAAC3NlZ...DITJheGo example@email.com
|
|
36
|
-
You can also find it here: /Users/savaryna/.ssh/git_email_example_name.pub
|
|
37
|
-
Add it to your favorite GIT provider and enjoy!
|
|
38
|
-
|
|
39
|
-
✨ Done. Thanks for using @savaryna/git-add-account!
|
|
28
|
+
gaa
|
|
40
29
|
```
|
|
41
30
|
|
|
42
|
-
|
|
31
|
+
After going through all the steps, you will be presented with your public SSH key so you can copy, and add it to your GIT provider. For example GitHub[^1]:
|
|
43
32
|
|
|
44
33
|
1. Go to your account [settings / keys](https://github.com/settings/keys)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
34
|
+
1. Click on `New SSH key`
|
|
35
|
+
1. Give it a title
|
|
36
|
+
1. Choose `Authentication Key` for key type
|
|
37
|
+
1. Paste in the public SSH key copied earlier in the key field
|
|
38
|
+
1. Click on `Add SSH key`
|
|
39
|
+
1. Repeat steps **2 through 6** to add a `Signing Key` key type, if you chose to sign your work (Commits, Tags, Pushes)[^2]
|
|
40
|
+
1. Done! Now, you can go to the workspace you chose for the account, ex: `cd /Users/john/code/work`, and all the `git`
|
|
41
|
+
commands issued from this, **or any other subdirectory**, will automatically use the correct account/ssh keys.
|
|
42
|
+
|
|
43
|
+
## Example of how it works
|
|
44
|
+
|
|
45
|
+
A simple way to use multiple git accounts on one machine is to use different SSH configs based on the directory you are in. The way [@savaryna/add-git-account](https://www.npmjs.com/package/@savaryna/git-add-account) works is, it asks you for some basic information and then it creates some files under `.config` in the workspace directory you specified. Ex:
|
|
46
|
+
|
|
47
|
+
1. It creates a _(private/public)_ SSH keypair using `ssh-keygen -t ed25519 -C "john@github.com" -f /Users/john/code/work/.config/id_ed25519_git_github_com`. [See code](https://github.com/savaryna/git-add-account/blob/main/index.js#L24-L25).
|
|
48
|
+
1. It creates a `sshconfig` file. [See code](https://github.com/savaryna/git-add-account/blob/main/index.js#L35-L47).
|
|
49
|
+
|
|
50
|
+
```ini
|
|
51
|
+
# File at /Users/john/code/work/.config/sshconfig
|
|
52
|
+
# Config for GIT account john@github.com
|
|
53
|
+
Host github.com
|
|
54
|
+
HostName github.com
|
|
55
|
+
User git
|
|
56
|
+
AddKeysToAgent yes
|
|
57
|
+
UseKeychain yes
|
|
58
|
+
IdentitiesOnly yes
|
|
59
|
+
IdentityFile /Users/john/code/work/.config/id_ed25519_git_github_com
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
1. It creates a `gitconfig` file. [See code](https://github.com/savaryna/git-add-account/blob/main/index.js#L49-L75).
|
|
63
|
+
|
|
64
|
+
```ini
|
|
65
|
+
# File at /Users/john/code/work/.config/gitconfig
|
|
66
|
+
# Config for GIT account john@github.com
|
|
67
|
+
[user]
|
|
68
|
+
name = John Doe
|
|
69
|
+
email = john@github.com
|
|
70
|
+
[core]
|
|
71
|
+
sshCommand = ssh -F /Users/john/code/work/.config/sshconfig
|
|
72
|
+
[gpg]
|
|
73
|
+
format = ssh
|
|
74
|
+
[commit]
|
|
75
|
+
gpgsign = true
|
|
76
|
+
[push]
|
|
77
|
+
gpgsign = if-asked
|
|
78
|
+
[tag]
|
|
79
|
+
gpgsign = true
|
|
80
|
+
[user]
|
|
81
|
+
signingkey = /Users/john/code/work/.config/id_ed25519_git_github_com
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
1. It runs `git config --global includeIf.gitdir:/Users/john/code/work/.path /Users/john/code/work/.config/gitconfig`, this makes sure that as long as you are in the workspace created earlier, **or any other subdirectory**, git will use the config from step **3** automatically[^3]. [See code](https://github.com/savaryna/git-add-account/blob/main/index.js#L77-L78).
|
|
85
|
+
1. And finally, it presents you with your public SSH key so you can copy it and add it to your GIT provider of choice.
|
|
79
86
|
|
|
80
87
|
## License
|
|
81
88
|
|
|
@@ -83,3 +90,4 @@ A simple way to use multiple git accounts on one machine is to use multiple SSH
|
|
|
83
90
|
|
|
84
91
|
[^1]: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account?tool=webui
|
|
85
92
|
[^2]: https://docs.github.com/en/authentication/managing-commit-signature-verification
|
|
93
|
+
[^3]: https://git-scm.com/docs/git-config#_conditional_includes
|
package/helpers/file.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const { access,
|
|
2
|
-
const { homedir } = require('os');
|
|
1
|
+
const { access, constants, mkdir, readFile, rm, writeFile } = require('fs');
|
|
2
|
+
const { homedir, platform } = require('os');
|
|
3
3
|
const { promisify } = require('util');
|
|
4
4
|
const { resolve } = require('path');
|
|
5
5
|
|
|
6
|
-
module.exports.
|
|
6
|
+
module.exports.createFile = (path, data) => promisify(writeFile)(path, data, 'utf8');
|
|
7
7
|
|
|
8
|
-
module.exports.
|
|
8
|
+
module.exports.readFile = promisify(readFile);
|
|
9
9
|
|
|
10
10
|
module.exports.home = homedir();
|
|
11
11
|
|
|
12
|
-
module.exports.
|
|
12
|
+
module.exports.platform = platform();
|
|
13
13
|
|
|
14
|
-
module.exports.
|
|
14
|
+
module.exports.mkdir = promisify(mkdir);
|
|
15
15
|
|
|
16
|
-
module.exports.remove = promisify(
|
|
16
|
+
module.exports.remove = (path) => promisify(rm)(path, { recursive: true, force: true });
|
|
17
17
|
|
|
18
18
|
module.exports.resolve = resolve;
|
|
19
19
|
|
package/helpers/prompts.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { default: exec } = require('./exec');
|
|
2
|
+
const { home, resolve } = require('./file');
|
|
3
|
+
const { default: validate, z } = require('./validate');
|
|
4
|
+
const defaultPrompts = require('prompts');
|
|
5
|
+
|
|
6
|
+
const MIN_GIT_VERSION = '2.34.0'; // Lower versions don't support SSH for GPG signing
|
|
7
|
+
|
|
8
|
+
const getGitVersion = () => exec('git --version').then(({ stdout }) => stdout.split(' ')[2]);
|
|
2
9
|
|
|
3
10
|
const exit = (code = 0, reason = null) => {
|
|
4
11
|
console.log(reason ? `\n${reason}\n` : '');
|
|
@@ -6,6 +13,98 @@ const exit = (code = 0, reason = null) => {
|
|
|
6
13
|
process.exit(code);
|
|
7
14
|
};
|
|
8
15
|
|
|
16
|
+
// Add onCancel handler for all prompts
|
|
17
|
+
const prompts = (questions, options) => defaultPrompts(questions, { onCancel: () => exit(1), ...options });
|
|
18
|
+
|
|
19
|
+
const overwritePathPrompt = (path) =>
|
|
20
|
+
prompts({
|
|
21
|
+
type: 'toggle',
|
|
22
|
+
name: 'overwrite',
|
|
23
|
+
message: `Path ${path} already exists. Overwrite?`,
|
|
24
|
+
initial: false,
|
|
25
|
+
active: 'yes',
|
|
26
|
+
inactive: 'no',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const cliPrompts = () =>
|
|
30
|
+
prompts([
|
|
31
|
+
{
|
|
32
|
+
type: 'text',
|
|
33
|
+
name: 'name',
|
|
34
|
+
message: 'Your name:',
|
|
35
|
+
validate: validate(z.string()),
|
|
36
|
+
format: (value) => ({
|
|
37
|
+
value,
|
|
38
|
+
camel: value.toLowerCase().replace(/[^\w]/g, '_'),
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'text',
|
|
43
|
+
name: 'email',
|
|
44
|
+
message: 'Email to use for this account:',
|
|
45
|
+
validate: validate(z.string().email()),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'text',
|
|
49
|
+
name: 'host',
|
|
50
|
+
message: 'Host to use for this account:',
|
|
51
|
+
initial: (email) => email.split('@')[1],
|
|
52
|
+
validate: validate(
|
|
53
|
+
z
|
|
54
|
+
.string()
|
|
55
|
+
.transform((h) => 'https://' + h)
|
|
56
|
+
.refine(URL.canParse, { message: 'Invalid host' })
|
|
57
|
+
),
|
|
58
|
+
format: (value) => ({
|
|
59
|
+
value,
|
|
60
|
+
camel: value.replace(/[^\w]/g, '_'),
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
type: 'text',
|
|
65
|
+
name: 'workspace',
|
|
66
|
+
message: 'Workspace to use for this account:',
|
|
67
|
+
initial: (host) => resolve(home, 'code', host.camel),
|
|
68
|
+
validate: validate(z.string().refine((value) => !value.startsWith('~'), { message: '"~" is not supported' })),
|
|
69
|
+
format: (value, { host }) => {
|
|
70
|
+
const root = resolve(home, value);
|
|
71
|
+
const config = resolve(root, '.config');
|
|
72
|
+
const sshKeyFileName = `id_ed25519_git_${host.camel}`;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
root,
|
|
76
|
+
config,
|
|
77
|
+
gitConfig: resolve(config, 'gitconfig'),
|
|
78
|
+
sshConfig: resolve(config, 'sshconfig'),
|
|
79
|
+
privateKey: resolve(config, sshKeyFileName),
|
|
80
|
+
publicKey: resolve(config, sshKeyFileName + '.pub'),
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'toggle',
|
|
86
|
+
name: 'signYourWork',
|
|
87
|
+
message: 'Do you want to sign your work with SSH?',
|
|
88
|
+
initial: true,
|
|
89
|
+
active: 'yes',
|
|
90
|
+
inactive: 'no',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: async (prev) => {
|
|
94
|
+
this.gitVersion = await getGitVersion();
|
|
95
|
+
return prev && this.gitVersion < MIN_GIT_VERSION ? 'toggle' : null;
|
|
96
|
+
},
|
|
97
|
+
name: 'signYourWork',
|
|
98
|
+
message: () => `Your current git version (${this.gitVersion}) does not support SSH signing. Continue without?`,
|
|
99
|
+
initial: true,
|
|
100
|
+
active: 'yes',
|
|
101
|
+
inactive: 'no',
|
|
102
|
+
format: (value) => (value ? !value : exit(1)),
|
|
103
|
+
},
|
|
104
|
+
]);
|
|
105
|
+
|
|
9
106
|
module.exports.exit = exit;
|
|
10
107
|
|
|
11
|
-
module.exports.
|
|
108
|
+
module.exports.overwritePathPrompt = overwritePathPrompt;
|
|
109
|
+
|
|
110
|
+
module.exports.default = cliPrompts;
|
package/index.js
CHANGED
|
@@ -1,149 +1,86 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { default: exec } = require('./helpers/exec');
|
|
4
|
-
const {
|
|
5
|
-
const { default: prompts, exit } = require('./helpers/prompts');
|
|
6
|
-
const { default: validate, z } = require('./helpers/validate');
|
|
7
|
-
|
|
8
|
-
const sshDirPath = resolve(home, '.ssh');
|
|
9
|
-
const sshConfigPath = resolve(sshDirPath, 'config');
|
|
10
|
-
|
|
11
|
-
const overwriteFilePrompt = (path) =>
|
|
12
|
-
prompts({
|
|
13
|
-
type: 'toggle',
|
|
14
|
-
name: 'overwrite',
|
|
15
|
-
message: `File ${path} already exists. Overwrite?`,
|
|
16
|
-
initial: false,
|
|
17
|
-
active: 'yes',
|
|
18
|
-
inactive: 'no',
|
|
19
|
-
});
|
|
4
|
+
const { createFile, hasReadWriteAccess, platform, mkdir, readFile, remove } = require('./helpers/file');
|
|
5
|
+
const { default: prompts, overwritePathPrompt, exit } = require('./helpers/prompts');
|
|
20
6
|
|
|
21
7
|
async function main() {
|
|
22
|
-
const { name, email, workspace } = await prompts(
|
|
23
|
-
{
|
|
24
|
-
type: 'text',
|
|
25
|
-
name: 'name',
|
|
26
|
-
message: 'Name to use for this account:',
|
|
27
|
-
validate: validate(z.string()),
|
|
28
|
-
format: (value) => ({
|
|
29
|
-
original: value,
|
|
30
|
-
camel: value.toLowerCase().replace(/[^\w]/g, '_'),
|
|
31
|
-
}),
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
type: 'text',
|
|
35
|
-
name: 'email',
|
|
36
|
-
message: 'Email to use for this account:',
|
|
37
|
-
validate: validate(z.string().email()),
|
|
38
|
-
format: (value) => ({
|
|
39
|
-
address: value,
|
|
40
|
-
domain: value.match(/(?<=@).+(?=\.)/)[0].replace(/[^\w]/g, '_'),
|
|
41
|
-
}),
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
type: 'text',
|
|
45
|
-
name: 'workspace',
|
|
46
|
-
message: 'Workspace to use for this account:',
|
|
47
|
-
initial: (email) => resolve(home, `code/${email.domain}`),
|
|
48
|
-
validate: validate(z.string()),
|
|
49
|
-
},
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
const workspaceGitConfigPath = resolve(workspace, '.gitconfig');
|
|
8
|
+
const { name, email, host, workspace, signYourWork } = await prompts();
|
|
53
9
|
|
|
54
|
-
|
|
55
|
-
|
|
10
|
+
// Check already existing workspace config
|
|
11
|
+
if (await hasReadWriteAccess(workspace.config)) {
|
|
12
|
+
const { overwrite } = await overwritePathPrompt(workspace.config);
|
|
56
13
|
|
|
57
14
|
if (overwrite) {
|
|
58
|
-
await remove(
|
|
15
|
+
await remove(workspace.config);
|
|
59
16
|
} else {
|
|
60
17
|
exit(1);
|
|
61
18
|
}
|
|
62
19
|
}
|
|
63
20
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
type: 'text',
|
|
67
|
-
name: 'sshKeyFileName',
|
|
68
|
-
message: 'Name to use for SSH keys:',
|
|
69
|
-
initial: `${email.domain}_${name.camel}`,
|
|
70
|
-
validate: validate(z.string()),
|
|
71
|
-
format: (value) => `git_${value}`,
|
|
72
|
-
},
|
|
73
|
-
]);
|
|
74
|
-
|
|
75
|
-
const sshKeyPath = resolve(sshDirPath, sshKeyFileName);
|
|
76
|
-
|
|
77
|
-
if (await hasReadWriteAccess(sshKeyPath)) {
|
|
78
|
-
const { overwrite } = await overwriteFilePrompt(sshKeyPath);
|
|
79
|
-
|
|
80
|
-
if (overwrite) {
|
|
81
|
-
await remove(sshKeyPath);
|
|
82
|
-
} else {
|
|
83
|
-
exit(1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
21
|
+
// Create workspace/config dir
|
|
22
|
+
await mkdir(workspace.config, { recursive: true });
|
|
86
23
|
|
|
87
24
|
// Generate ssh key
|
|
88
|
-
await exec(`ssh-keygen -t ed25519 -C "${email
|
|
25
|
+
await exec(`ssh-keygen -t ed25519 -C "${email}" -f ${workspace.privateKey}`);
|
|
89
26
|
|
|
90
|
-
//
|
|
91
|
-
const
|
|
92
|
-
(
|
|
93
|
-
|
|
94
|
-
|
|
27
|
+
// Use keychain if the system is MacOS and a passphrase was used
|
|
28
|
+
const useKeychain = await exec(`ssh-keygen -y -P "" -f ${workspace.privateKey}`)
|
|
29
|
+
.then(
|
|
30
|
+
() => false,
|
|
31
|
+
() => true
|
|
32
|
+
)
|
|
33
|
+
.then((hasPassphrase) => hasPassphrase && platform === 'darwin');
|
|
95
34
|
|
|
35
|
+
// Create sshconfig for the workspace
|
|
96
36
|
const sshConfig = `
|
|
97
|
-
# Config for GIT account ${email
|
|
98
|
-
Host
|
|
37
|
+
# Config for GIT account ${email}
|
|
38
|
+
Host ${host.value}
|
|
39
|
+
HostName ${host.value}
|
|
40
|
+
User git
|
|
99
41
|
AddKeysToAgent yes
|
|
100
|
-
${
|
|
101
|
-
|
|
42
|
+
${useKeychain ? 'UseKeychain yes' : ''}
|
|
43
|
+
IdentitiesOnly yes
|
|
44
|
+
IdentityFile ${workspace.privateKey}
|
|
102
45
|
`.replace(/\n\s{4}/g, '\n');
|
|
103
46
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
47
|
+
await createFile(workspace.sshConfig, sshConfig);
|
|
48
|
+
|
|
49
|
+
// Create gitconfig for the workspace
|
|
50
|
+
const gitConfig = `
|
|
51
|
+
# Config for GIT account ${email}
|
|
52
|
+
[user]
|
|
53
|
+
name = ${name.value}
|
|
54
|
+
email = ${email}
|
|
55
|
+
[core]
|
|
56
|
+
sshCommand = ssh -F ${workspace.sshConfig}
|
|
57
|
+
${
|
|
58
|
+
!signYourWork
|
|
59
|
+
? ''
|
|
60
|
+
: `
|
|
61
|
+
[gpg]
|
|
62
|
+
format = ssh
|
|
63
|
+
[commit]
|
|
64
|
+
gpgsign = true
|
|
65
|
+
[push]
|
|
66
|
+
gpgsign = if-asked
|
|
67
|
+
[tag]
|
|
68
|
+
gpgsign = true
|
|
69
|
+
[user]
|
|
70
|
+
signingkey = ${workspace.privateKey}
|
|
71
|
+
`
|
|
72
|
+
}
|
|
73
|
+
`.replace(/\n\s{4}/g, '\n');
|
|
128
74
|
|
|
129
|
-
|
|
130
|
-
if (signYourWork) {
|
|
131
|
-
await exec(`git config --file ${workspaceGitConfigPath} gpg.format ssh`);
|
|
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`);
|
|
135
|
-
await exec(`git config --file ${workspaceGitConfigPath} user.signingkey ${sshKeyPath}`);
|
|
136
|
-
}
|
|
75
|
+
await createFile(workspace.gitConfig, gitConfig);
|
|
137
76
|
|
|
138
77
|
// Include workspace config in the global config
|
|
139
|
-
await exec(`git config --global includeIf.gitdir:${workspace}/.path ${
|
|
78
|
+
await exec(`git config --global includeIf.gitdir:${workspace.root}/.path ${workspace.gitConfig}`);
|
|
140
79
|
|
|
141
|
-
const
|
|
142
|
-
// await exec(`pbcopy < ${publicSshKeyPath}`);
|
|
143
|
-
const publicSshKey = await readFile(publicSshKeyPath).then((buffer) => buffer.toString().trim());
|
|
80
|
+
const publicKey = await readFile(workspace.publicKey).then((buffer) => buffer.toString().trim());
|
|
144
81
|
|
|
145
|
-
console.log('\nYour public SSH key is: ',
|
|
146
|
-
console.log('You can also find it here: ',
|
|
82
|
+
console.log('\nYour public SSH key is: ', publicKey);
|
|
83
|
+
console.log('You can also find it here: ', workspace.publicKey);
|
|
147
84
|
console.log('Add it to your favorite GIT provider and enjoy!');
|
|
148
85
|
}
|
|
149
86
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savaryna/git-add-account",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
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": [
|
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
"url": "git+https://github.com/savaryna/git-add-account.git"
|
|
34
34
|
},
|
|
35
35
|
"type": "commonjs",
|
|
36
|
+
"files": [
|
|
37
|
+
"helpers"
|
|
38
|
+
],
|
|
36
39
|
"bin": {
|
|
37
40
|
"gaa": "index.js",
|
|
38
41
|
"git-add-account": "index.js"
|
package/.github/dependabot.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
-
# package ecosystems to update and where the package manifests are located.
|
|
3
|
-
# Please see the documentation for all configuration options:
|
|
4
|
-
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
-
|
|
6
|
-
version: 2
|
|
7
|
-
updates:
|
|
8
|
-
|
|
9
|
-
# Maintain dependencies for GitHub Actions
|
|
10
|
-
- package-ecosystem: "github-actions"
|
|
11
|
-
directory: "/"
|
|
12
|
-
schedule:
|
|
13
|
-
interval: "monthly"
|
|
14
|
-
|
|
15
|
-
# Maintain dependencies for npm
|
|
16
|
-
- package-ecosystem: "npm"
|
|
17
|
-
directory: "/"
|
|
18
|
-
schedule:
|
|
19
|
-
interval: "monthly"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: Publish package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [created]
|
|
6
|
-
workflow_dispatch:
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish-npm:
|
|
10
|
-
runs-on: macos-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v3
|
|
13
|
-
- uses: actions/setup-node@v3
|
|
14
|
-
with:
|
|
15
|
-
node-version: 20
|
|
16
|
-
registry-url: https://registry.npmjs.org/
|
|
17
|
-
scope: '@savaryna'
|
|
18
|
-
- run: npm ci
|
|
19
|
-
- run: npm publish --access=public
|
|
20
|
-
env:
|
|
21
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/.prettierrc.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"arrowParens": "always",
|
|
3
|
-
"bracketSameLine": false,
|
|
4
|
-
"bracketSpacing": true,
|
|
5
|
-
"embeddedLanguageFormatting": "auto",
|
|
6
|
-
"htmlWhitespaceSensitivity": "css",
|
|
7
|
-
"insertPragma": false,
|
|
8
|
-
"jsxSingleQuote": false,
|
|
9
|
-
"printWidth": 120,
|
|
10
|
-
"proseWrap": "preserve",
|
|
11
|
-
"quoteProps": "as-needed",
|
|
12
|
-
"requirePragma": false,
|
|
13
|
-
"semi": true,
|
|
14
|
-
"singleAttributePerLine": false,
|
|
15
|
-
"singleQuote": true,
|
|
16
|
-
"tabWidth": 2,
|
|
17
|
-
"trailingComma": "es5",
|
|
18
|
-
"useTabs": false,
|
|
19
|
-
"vueIndentScriptAndStyle": false
|
|
20
|
-
}
|