@gkalpak/aliases 0.9.1 → 0.9.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 +1 -1
- package/bin/config/cfgbash.js +1 -2
- package/bin/config/cfgbash.wsl.js +22 -0
- package/bin/config/cfggit.js +5 -2
- package/bin/config/cfggit.wsl.js +5 -2
- package/bin/config/cfgvim.js +1 -1
- package/bin/git/gbcm.js +1 -1
- package/bin/git/gcom.js +1 -1
- package/bin/git/gdefb.js +11 -0
- package/bin/git/gprom.js +1 -1
- package/bin/git/gprum.js +1 -1
- package/bin/git/grbm.js +1 -1
- package/bin/git/gsync.js +1 -1
- package/bin/misc/alv.js +1 -1
- package/lib/alias-scripts/gcoghpr.js +10 -6
- package/lib/alias.js +2 -1
- package/lib/constants.js +130 -111
- package/lib/helper.js +2 -2
- package/lib/utils.js +2 -2
- package/package.json +9 -8
- package/scripts/test-pkg.js +12 -12
- package/bin/config/cfggit.win32.js +0 -18
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ inspecting the associated command (e.g. via `halp`).
|
|
|
54
54
|
|
|
55
55
|
Here is the list of all global dependencies with associated min. version (older versions are not guaranteed work):
|
|
56
56
|
|
|
57
|
-
- `git`: [git] >=
|
|
57
|
+
- `git`: [git] >=2.35
|
|
58
58
|
- `docker`: [docker] >= 17
|
|
59
59
|
- `grep`: [grep] >=3 (could come through a bash emulation environment on Windows, such as [git for
|
|
60
60
|
Windows][git-win]' `Git BASH`)
|
package/bin/config/cfgbash.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const utils = require('../../lib/utils');
|
|
4
4
|
/* eslint-disable max-len */
|
|
5
5
|
console.log(utils.stripIndentation(`
|
|
6
|
-
### [Generated by: @gkalpak/aliases v0.9.
|
|
6
|
+
### [Generated by: @gkalpak/aliases v0.9.4]
|
|
7
7
|
### Copy the following into '~/.bashrc':
|
|
8
8
|
|
|
9
9
|
# Set up prompt.
|
|
@@ -17,4 +17,3 @@ console.log(utils.stripIndentation(`
|
|
|
17
17
|
|
|
18
18
|
`));
|
|
19
19
|
/* eslint-enable max-len */
|
|
20
|
-
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
const utils = require('../../lib/utils');
|
|
4
|
+
/* eslint-disable max-len */
|
|
5
|
+
console.log(utils.stripIndentation(`
|
|
6
|
+
### [Generated by: @gkalpak/aliases v0.9.4]
|
|
7
|
+
### Copy the following into '~/.bashrc':
|
|
8
|
+
|
|
9
|
+
# Set up prompt.
|
|
10
|
+
PS1='\\[\\033[90m\\][\\d \\t]\\[\\033[00m\\]\\n\${debian_chroot:+($debian_chroot)}\\[\\033[01;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]$ ';
|
|
11
|
+
|
|
12
|
+
# Improve tab completion.
|
|
13
|
+
bind "set completion-ignore-case on";
|
|
14
|
+
bind "set menu-complete-display-prefix on";
|
|
15
|
+
bind "set show-all-if-ambiguous on";
|
|
16
|
+
bind "TAB:menu-complete";
|
|
17
|
+
|
|
18
|
+
# Fix required for GPG signing in WSL.
|
|
19
|
+
export GPG_TTY="$(tty)";
|
|
20
|
+
|
|
21
|
+
`));
|
|
22
|
+
/* eslint-enable max-len */
|
package/bin/config/cfggit.js
CHANGED
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
const utils = require('../../lib/utils');
|
|
4
4
|
console.log(utils.stripIndentation(`
|
|
5
|
-
### [Generated by: @gkalpak/aliases v0.9.
|
|
5
|
+
### [Generated by: @gkalpak/aliases v0.9.4]
|
|
6
6
|
### Run the following commands:
|
|
7
7
|
|
|
8
|
+
git config --global commit.gpgSign true
|
|
8
9
|
git config --global core.editor "vim"
|
|
9
|
-
git config --global credential.helper "
|
|
10
|
+
git config --global credential.helper "manager"
|
|
10
11
|
git config --global merge.tool "kdiff3"
|
|
11
12
|
git config --global mergetool.kdiff3.path "/path/to/kdiff3"
|
|
12
13
|
git config --global mergetool.kdiff3.trustExitCode "false"
|
|
13
14
|
git config --global push.default "upstream"
|
|
14
15
|
git config --global rebase.autosquash "true"
|
|
15
16
|
git config --global rebase.autostash "true"
|
|
17
|
+
git config --global tag.gpgSign true
|
|
16
18
|
git config --global user.email "kalpakas.g@gmail.com"
|
|
17
19
|
git config --global user.name "George Kalpakas"
|
|
20
|
+
git config --global user.signingKey "0FF21FC44ECE9F07"
|
|
18
21
|
`));
|
package/bin/config/cfggit.wsl.js
CHANGED
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
const utils = require('../../lib/utils');
|
|
4
4
|
console.log(utils.stripIndentation(`
|
|
5
|
-
### [Generated by: @gkalpak/aliases v0.9.
|
|
5
|
+
### [Generated by: @gkalpak/aliases v0.9.4]
|
|
6
6
|
### Run the following commands:
|
|
7
7
|
|
|
8
|
+
git config --global commit.gpgSign true
|
|
8
9
|
git config --global core.editor "vim"
|
|
9
|
-
git config --global credential.helper "/mnt/c/Program\\ Files/Git/mingw64/
|
|
10
|
+
git config --global credential.helper "/mnt/c/Program\\ Files/Git/mingw64/bin/git-credential-manager-core.exe"
|
|
10
11
|
git config --global merge.tool "kdiff3"
|
|
11
12
|
git config --global mergetool.kdiff3.path "/path/to/kdiff3"
|
|
12
13
|
git config --global mergetool.kdiff3.trustExitCode "false"
|
|
13
14
|
git config --global push.default "upstream"
|
|
14
15
|
git config --global rebase.autosquash "true"
|
|
15
16
|
git config --global rebase.autostash "true"
|
|
17
|
+
git config --global tag.gpgSign true
|
|
16
18
|
git config --global user.email "kalpakas.g@gmail.com"
|
|
17
19
|
git config --global user.name "George Kalpakas"
|
|
20
|
+
git config --global user.signingKey "0FF21FC44ECE9F07"
|
|
18
21
|
`));
|
package/bin/config/cfgvim.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
|
-
console.log('""" [Generated by: @gkalpak/aliases v0.9.
|
|
3
|
+
console.log('""" [Generated by: @gkalpak/aliases v0.9.4]');
|
|
4
4
|
console.log('""" Copy the following into \'~/.vimrc\':\n');
|
|
5
5
|
console.log(require('fs').readFileSync(`${__dirname}/../../lib/assets/vimrc.txt`, 'utf8').trim() + '\n');
|
package/bin/git/gbcm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd = module.exports = 'git checkout master -b $1 && git config branch.$1.remote origin && git config branch.$1.merge refs/heads/$1';
|
|
4
|
+
const cmd = module.exports = 'git checkout ${0:::(git show-ref --heads --quiet master && echo master) || (git show-ref --heads --quiet main && echo main) || echo unknown-branch} -b $1 && git config branch.$1.remote origin && git config branch.$1.merge refs/heads/$1';
|
|
5
5
|
if (require.main === module) {
|
|
6
6
|
const {commandUtils} = require('@gkalpak/cli-utils');
|
|
7
7
|
const {onError} = require('../../lib/utils');
|
package/bin/git/gcom.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd = module.exports = 'git checkout master $*';
|
|
4
|
+
const cmd = module.exports = 'git checkout ${0:::(git show-ref --heads --quiet master && echo master) || (git show-ref --heads --quiet main && echo main) || echo unknown-branch} $*';
|
|
5
5
|
if (require.main === module) {
|
|
6
6
|
const {commandUtils} = require('@gkalpak/cli-utils');
|
|
7
7
|
const {onError} = require('../../lib/utils');
|
package/bin/git/gdefb.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
// eslint-disable-next-line max-len
|
|
4
|
+
const cmd = module.exports = '(git show-ref --heads --quiet master && echo master) || (git show-ref --heads --quiet main && echo main) || echo unknown-branch';
|
|
5
|
+
if (require.main === module) {
|
|
6
|
+
const {commandUtils} = require('@gkalpak/cli-utils');
|
|
7
|
+
const {onError} = require('../../lib/utils');
|
|
8
|
+
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
9
|
+
// eslint-disable-next-line quotes
|
|
10
|
+
commandUtils.run(cmd, args, Object.assign({"sapVersion":2}, config)).catch(onError);
|
|
11
|
+
}
|
package/bin/git/gprom.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd = module.exports = 'git pull --rebase origin master $*';
|
|
4
|
+
const cmd = module.exports = 'git pull --rebase origin ${0:::(git show-ref --heads --quiet master && echo master) || (git show-ref --heads --quiet main && echo main) || echo unknown-branch} $*';
|
|
5
5
|
if (require.main === module) {
|
|
6
6
|
const {commandUtils} = require('@gkalpak/cli-utils');
|
|
7
7
|
const {onError} = require('../../lib/utils');
|
package/bin/git/gprum.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd = module.exports = 'git pull --rebase upstream master $*';
|
|
4
|
+
const cmd = module.exports = 'git pull --rebase upstream ${0:::(git show-ref --heads --quiet master && echo master) || (git show-ref --heads --quiet main && echo main) || echo unknown-branch} $*';
|
|
5
5
|
if (require.main === module) {
|
|
6
6
|
const {commandUtils} = require('@gkalpak/cli-utils');
|
|
7
7
|
const {onError} = require('../../lib/utils');
|
package/bin/git/grbm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd = module.exports = 'git rebase --ignore-date master $*';
|
|
4
|
+
const cmd = module.exports = 'git rebase --ignore-date ${0:::(git show-ref --heads --quiet master && echo master) || (git show-ref --heads --quiet main && echo main) || echo unknown-branch} $*';
|
|
5
5
|
if (require.main === module) {
|
|
6
6
|
const {commandUtils} = require('@gkalpak/cli-utils');
|
|
7
7
|
const {onError} = require('../../lib/utils');
|
package/bin/git/gsync.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd = module.exports = 'git checkout ${1
|
|
4
|
+
const cmd = module.exports = 'git checkout ${1:::(git show-ref --heads --quiet master && echo master) || (git show-ref --heads --quiet main && echo main) || echo unknown-branch} && git pull upstream ${1:::(git show-ref --heads --quiet master && echo master) || (git show-ref --heads --quiet main && echo main) || echo unknown-branch} && git push origin ${1:::(git show-ref --heads --quiet master && echo master) || (git show-ref --heads --quiet main && echo main) || echo unknown-branch}';
|
|
5
5
|
if (require.main === module) {
|
|
6
6
|
const {commandUtils} = require('@gkalpak/cli-utils');
|
|
7
7
|
const {onError} = require('../../lib/utils');
|
package/bin/misc/alv.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
// Imports
|
|
@@ -46,7 +47,7 @@ class _Gcoghpr {
|
|
|
46
47
|
* 1. Guess the upstream URL (looking at remotes `upstream` or `origin`).
|
|
47
48
|
* 2. Retrieve the PR author and branch (either extracting it from the input or fetching it from GitHub).
|
|
48
49
|
* 3. Check if a local branch with the same name already exists. (If it does, ask for permission to overwrite it.)
|
|
49
|
-
* 4. Check out
|
|
50
|
+
* 4. Check out the default branch.
|
|
50
51
|
* 5. Fetch the PR branch from the author's remote into a local branch (with the same name).
|
|
51
52
|
* 6. Switch to the new branch.
|
|
52
53
|
* 7. Set up the local branch to track the PR branch.
|
|
@@ -103,7 +104,10 @@ class _Gcoghpr {
|
|
|
103
104
|
then(() => executor.exec(`git show-ref --heads --quiet ${localBranch}`).
|
|
104
105
|
then(() => this._confirmOverwriteBranch(localBranch), () => undefined)).
|
|
105
106
|
then(() => executor.execForOutput('git rev-parse --abbrev-ref HEAD')).
|
|
106
|
-
then(currentBranch =>
|
|
107
|
+
then(currentBranch =>
|
|
108
|
+
(currentBranch === localBranch) &&
|
|
109
|
+
executor.execForOutput(this._constants.ALIASES.git.gdefb.getSpec().command).
|
|
110
|
+
then(defaultBranch => executor.exec(`git checkout ${defaultBranch}`))).
|
|
107
111
|
then(() => executor.exec(`git remote remove ${remoteAlias} || true`)).
|
|
108
112
|
then(() => executor.exec(`git remote add ${remoteAlias} ${originUrl}`)).
|
|
109
113
|
then(() => executor.exec(`git fetch --no-tags ${remoteAlias} ${branch}`)).
|
|
@@ -123,8 +127,8 @@ class _Gcoghpr {
|
|
|
123
127
|
return new Promise((resolve, reject) => {
|
|
124
128
|
const rlInstance = this._rl.createInterface(process.stdin, process.stdout);
|
|
125
129
|
const question = chalk.yellow(
|
|
126
|
-
|
|
127
|
-
|
|
130
|
+
`Branch '${branch}' does already exist.\n` +
|
|
131
|
+
`Overwrite it? ${chalk.white('[y/N]')} `);
|
|
128
132
|
|
|
129
133
|
rlInstance.question(question, answer => {
|
|
130
134
|
rlInstance.close();
|
|
@@ -278,8 +282,8 @@ class GitHubUtils {
|
|
|
278
282
|
if (!ghToken && !this._shownTokenWarning) {
|
|
279
283
|
this._shownTokenWarning = true;
|
|
280
284
|
this._logger.warn(
|
|
281
|
-
|
|
282
|
-
|
|
285
|
+
`No GitHub access token found in \`${GH_TOKEN_NAME}\` environment variable.\n` +
|
|
286
|
+
'Proceeding anonymously (and subject to rate-limiting)...');
|
|
283
287
|
}
|
|
284
288
|
|
|
285
289
|
return this._httpsGet(url, options).then(responseText => {
|
package/lib/alias.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
// Imports
|
|
@@ -65,7 +66,7 @@ class AliasSpec/* implements IAliasSpec */ {
|
|
|
65
66
|
|
|
66
67
|
class AliasSpecDefault extends AliasSpec {
|
|
67
68
|
static DEF_CODE() {
|
|
68
|
-
throw new Error('
|
|
69
|
+
throw new Error('This method is supposed to be overwritten, before any instances are created.');
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
constructor(command/* string */, config/*? IRunConfig */) {
|
package/lib/constants.js
CHANGED
|
@@ -12,6 +12,9 @@ const VERSION_STAMP = `${pkg.name} v${pkg.version}`;
|
|
|
12
12
|
const ROOT_DIR = path.resolve(__dirname, '..');
|
|
13
13
|
const BIN_DIR = path.join(ROOT_DIR, 'bin');
|
|
14
14
|
const SOURCE_NVM_CMD = '. $NVM_DIR/nvm.sh';
|
|
15
|
+
const GIT_GET_DEFAULT_BRANCH_CMD =
|
|
16
|
+
`${['master', 'main'].map(b => `(git show-ref --heads --quiet ${b} && echo ${b})`).join(' || ')} || ` +
|
|
17
|
+
'echo unknown-branch';
|
|
15
18
|
const GLOBAL_NPM_PACKAGES = [
|
|
16
19
|
'@angular/cli',
|
|
17
20
|
'@gkalpak/aliases',
|
|
@@ -33,6 +36,7 @@ const GLOBAL_NPM_PACKAGES = [
|
|
|
33
36
|
|
|
34
37
|
const DESC_REPLACEMENTS = {
|
|
35
38
|
[AliasUnknown.DESCRIPTION]: '???',
|
|
39
|
+
[`::${GIT_GET_DEFAULT_BRANCH_CMD}`]: '<default-branch>',
|
|
36
40
|
'::__a-builds-dir': '(<.../angular/aio/aio-builds-setup>)',
|
|
37
41
|
'::__g-pick-branch --gkcu-returnOutput=1': '(interactively pick a branch)',
|
|
38
42
|
'::__g-pick-commit --gkcu-returnOutput=1': '(interactively pick a commit)',
|
|
@@ -52,28 +56,60 @@ const DEF_CODE = AliasSpecDefault.DEF_CODE = (cmd, cfg = {}) => utils.stripInden
|
|
|
52
56
|
}
|
|
53
57
|
`);
|
|
54
58
|
|
|
59
|
+
const CFGBASH_SPEC = isWsl => new AliasSpec(
|
|
60
|
+
/* eslint-disable max-len */
|
|
61
|
+
utils.stripIndentation(`
|
|
62
|
+
#!/usr/bin/env node
|
|
63
|
+
'use strict';
|
|
64
|
+
const utils = require('../../lib/utils');
|
|
65
|
+
/* eslint-disable max-len */
|
|
66
|
+
console.log(utils.stripIndentation(\`
|
|
67
|
+
### [Generated by: ${VERSION_STAMP}]
|
|
68
|
+
### Copy the following into '~/.bashrc':
|
|
69
|
+
|
|
70
|
+
# Set up prompt.
|
|
71
|
+
PS1='\\\\[\\\\033[90m\\\\][\\\\d \\\\t]\\\\[\\\\033[00m\\\\]\\\\n\\\${debian_chroot:+($debian_chroot)}\\\\[\\\\033[01;32m\\\\]\\\\u@\\\\h\\\\[\\\\033[00m\\\\]:\\\\[\\\\033[01;34m\\\\]\\\\w\\\\[\\\\033[00m\\\\]$ ';
|
|
72
|
+
|
|
73
|
+
# Improve tab completion.
|
|
74
|
+
bind "set completion-ignore-case on";
|
|
75
|
+
bind "set menu-complete-display-prefix on";
|
|
76
|
+
bind "set show-all-if-ambiguous on";
|
|
77
|
+
bind "TAB:menu-complete";${!isWsl ? '' : `
|
|
78
|
+
|
|
79
|
+
# Fix required for GPG signing in WSL.
|
|
80
|
+
export GPG_TTY="$(tty)";`}
|
|
81
|
+
|
|
82
|
+
\`));
|
|
83
|
+
/* eslint-enable max-len */
|
|
84
|
+
`),
|
|
85
|
+
/* eslint-enable max-len */
|
|
86
|
+
'Show configuration instructions for `bash`.');
|
|
87
|
+
|
|
55
88
|
const CFGGIT_SPEC_WITH_CRED_HELPER = credHelper => new AliasSpec(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
89
|
+
utils.stripIndentation(`
|
|
90
|
+
#!/usr/bin/env node
|
|
91
|
+
'use strict';
|
|
92
|
+
const utils = require('../../lib/utils');
|
|
93
|
+
console.log(utils.stripIndentation(\`
|
|
94
|
+
### [Generated by: ${VERSION_STAMP}]
|
|
95
|
+
### Run the following commands:
|
|
96
|
+
|
|
97
|
+
git config --global commit.gpgSign true
|
|
98
|
+
git config --global core.editor "vim"
|
|
99
|
+
git config --global credential.helper "${credHelper}"
|
|
100
|
+
git config --global merge.tool "kdiff3"
|
|
101
|
+
git config --global mergetool.kdiff3.path "/path/to/kdiff3"
|
|
102
|
+
git config --global mergetool.kdiff3.trustExitCode "false"
|
|
103
|
+
git config --global push.default "upstream"
|
|
104
|
+
git config --global rebase.autosquash "true"
|
|
105
|
+
git config --global rebase.autostash "true"
|
|
106
|
+
git config --global tag.gpgSign true
|
|
107
|
+
git config --global user.email "kalpakas.g@gmail.com"
|
|
108
|
+
git config --global user.name "George Kalpakas"
|
|
109
|
+
git config --global user.signingKey "0FF21FC44ECE9F07"
|
|
110
|
+
\`));
|
|
111
|
+
`),
|
|
112
|
+
'Show configuration instructions for `git`.');
|
|
77
113
|
|
|
78
114
|
const SCRIPT_BACKED_CODE = (scriptName, desc) => utils.stripIndentation(`
|
|
79
115
|
#!/usr/bin/env node
|
|
@@ -168,6 +204,7 @@ const ALIASES = {
|
|
|
168
204
|
git: {
|
|
169
205
|
// STATUS
|
|
170
206
|
gs: new AliasDefault('git status $*'),
|
|
207
|
+
gdefb: new AliasDefault(GIT_GET_DEFAULT_BRANCH_CMD),
|
|
171
208
|
gl: new AliasDefault('git log --decorate $* || true'),
|
|
172
209
|
gl1: new AliasDefault('git log --decorate --oneline $* || true'),
|
|
173
210
|
gl1g: new AliasDefault('git log --decorate --oneline | grep $*'),
|
|
@@ -188,13 +225,13 @@ const ALIASES = {
|
|
|
188
225
|
|
|
189
226
|
// CHECKOUT
|
|
190
227
|
gco: new AliasDefault('git checkout ${*:::__g-pick-branch --gkcu-returnOutput=1}'),
|
|
191
|
-
gcom: new AliasDefault(
|
|
228
|
+
gcom: new AliasDefault(`git checkout \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} $*`),
|
|
192
229
|
gcopr: new AliasDefault('git fetch upstream pull/$1/head && git checkout FETCH_HEAD'),
|
|
193
230
|
gcoghpr: SCRIPT_BACKED_ALIAS('gcoghpr', 'Check out a GitHub pull request as a local branch.'),
|
|
194
231
|
'gcoghpr-cleanup': new AliasDefault(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
232
|
+
CLEANUP_CODE('git branches', `${PR_LOCAL_BRANCH_PREFIX}-`, 'git branch', 'git branch --delete --force') +
|
|
233
|
+
' && ' +
|
|
234
|
+
CLEANUP_CODE('git remotes', `${PR_REMOTE_ALIAS_PREFIX}-`, 'git remote show', 'git remote remove')),
|
|
198
235
|
|
|
199
236
|
// ADD / COMMIT
|
|
200
237
|
gaa: new AliasDefault('git add --all $*'),
|
|
@@ -224,25 +261,30 @@ const ALIASES = {
|
|
|
224
261
|
// BRANCH
|
|
225
262
|
gb: new AliasDefault('git branch $*'),
|
|
226
263
|
gbc: new AliasDefault(
|
|
227
|
-
|
|
264
|
+
'git checkout ${2:HEAD} -b $1 && git config branch.$1.remote origin && ' +
|
|
265
|
+
'git config branch.$1.merge refs/heads/$1'),
|
|
228
266
|
gbcm: new AliasDefault(
|
|
229
|
-
|
|
267
|
+
`git checkout \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} -b $1 && git config branch.$1.remote origin && ` +
|
|
268
|
+
'git config branch.$1.merge refs/heads/$1'),
|
|
230
269
|
gbd: new AliasDefault('git branch --delete --force ${*:::__g-pick-branch --gkcu-returnOutput=1}'),
|
|
231
270
|
|
|
232
271
|
// PULL(-REBASE)
|
|
233
272
|
gpr: new AliasDefault('git pull --rebase $*'),
|
|
234
273
|
gpro: new AliasDefault('git pull --rebase origin ${*:::git rev-parse --abbrev-ref HEAD}'),
|
|
235
|
-
gprom: new AliasDefault(
|
|
274
|
+
gprom: new AliasDefault(`git pull --rebase origin \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} $*`),
|
|
236
275
|
gpru: new AliasDefault('git pull --rebase upstream ${*:::git rev-parse --abbrev-ref HEAD}'),
|
|
237
|
-
gprum: new AliasDefault(
|
|
276
|
+
gprum: new AliasDefault(`git pull --rebase upstream \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} $*`),
|
|
238
277
|
|
|
239
|
-
// SYNC
|
|
240
|
-
gsync: new AliasDefault(
|
|
278
|
+
// SYNC DEFAULT BRANCH
|
|
279
|
+
gsync: new AliasDefault(
|
|
280
|
+
`git checkout \${1:::${GIT_GET_DEFAULT_BRANCH_CMD}} && ` +
|
|
281
|
+
`git pull upstream \${1:::${GIT_GET_DEFAULT_BRANCH_CMD}} && ` +
|
|
282
|
+
`git push origin \${1:::${GIT_GET_DEFAULT_BRANCH_CMD}}`),
|
|
241
283
|
|
|
242
284
|
|
|
243
285
|
// REBASE
|
|
244
286
|
grb: new AliasDefault('git rebase ${*:::__g-pick-branch --gkcu-returnOutput=1}'),
|
|
245
|
-
grbm: new AliasDefault(
|
|
287
|
+
grbm: new AliasDefault(`git rebase --ignore-date \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} $*`),
|
|
246
288
|
grbi: new AliasDefault('git rebase --interactive HEAD~$1'),
|
|
247
289
|
grbia: new AliasDefault('git rebase --autosquash --interactive HEAD~$1'),
|
|
248
290
|
grbin: new AliasDefault('git rebase --no-autosquash --interactive HEAD~$1'),
|
|
@@ -304,30 +346,30 @@ const ALIASES = {
|
|
|
304
346
|
}),
|
|
305
347
|
nvu: new Alias({
|
|
306
348
|
default: new AliasSpec(
|
|
307
|
-
|
|
308
|
-
|
|
349
|
+
SCRIPT_BACKED_CODE('nvu', 'nvm use $*'),
|
|
350
|
+
`${SOURCE_NVM_CMD} && nvm use $* (it does not affect the currect process)`),
|
|
309
351
|
win32: new AliasSpec(
|
|
310
|
-
|
|
311
|
-
|
|
352
|
+
SCRIPT_BACKED_CODE('nvu', 'nvm use $*'),
|
|
353
|
+
'nvm use $* (the 1st arg is replaced with the latest available version on the specified branch)'),
|
|
312
354
|
}),
|
|
313
355
|
nvmup: new Alias({
|
|
314
356
|
default: new AliasSpecDefault(
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
357
|
+
PRINT_NVM_UPDATE_INSTRUCTIONS_CODE(
|
|
358
|
+
`${SOURCE_NVM_CMD} && nvm --version`,
|
|
359
|
+
'nvm-sh/nvm',
|
|
360
|
+
'install--update-script',
|
|
361
|
+
'Run: \'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v{{version}}/install.sh | bash\' ' +
|
|
362
|
+
'(or \'wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v{{version}}/install.sh | bash\')',
|
|
363
|
+
),
|
|
322
364
|
),
|
|
323
365
|
win32: new AliasSpecDefault(
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
366
|
+
PRINT_NVM_UPDATE_INSTRUCTIONS_CODE(
|
|
367
|
+
'nvm version',
|
|
368
|
+
'coreybutler/nvm-windows',
|
|
369
|
+
'installation--upgrades',
|
|
370
|
+
'Download, unzip and run: ' +
|
|
371
|
+
'https://github.com/coreybutler/nvm-windows/releases/download/{{version}}/nvm-setup.zip',
|
|
372
|
+
),
|
|
331
373
|
),
|
|
332
374
|
}),
|
|
333
375
|
|
|
@@ -380,8 +422,8 @@ const ALIASES = {
|
|
|
380
422
|
// SPECIAL
|
|
381
423
|
srv: new AliasDefault('http-server "${1:.}" --port="4000" $2*'),
|
|
382
424
|
srvw: new AliasDefault(
|
|
383
|
-
|
|
384
|
-
|
|
425
|
+
'light-server --bind="localhost" --historyindex="/index.html" --serve="${1:.}" --watchexp="${1:.}/**" $2*',
|
|
426
|
+
{suppressTbj: true}),
|
|
385
427
|
naga: new AliasDefault(`npm install --global ${GLOBAL_NPM_PACKAGES.join(' ')} $*`),
|
|
386
428
|
yaga: new AliasDefault(`yarn global add ${GLOBAL_NPM_PACKAGES.filter(x => !/^yarn(?:@|$)/.test(x)).join(' ')} $*`),
|
|
387
429
|
},
|
|
@@ -392,7 +434,7 @@ const ALIASES = {
|
|
|
392
434
|
dkrrm: new AliasDefault('docker stop $1 & docker rm $1 || true'),
|
|
393
435
|
dkrbd: new AliasDefault('docker build --tag $1 $3* $2'),
|
|
394
436
|
dkrrd: new AliasDefault(
|
|
395
|
-
|
|
437
|
+
'docker run -d --name $1 -p 4000:4000 -p 4200:4200 -p 4433:4433 -p 8080:8080 -p 9876:9876 $3* $2'),
|
|
396
438
|
dkratt: new AliasDefault('docker exec -it $1 /bin/bash $2*'),
|
|
397
439
|
dkrall: new AliasDefault('dkrrm $1 && dkrbd $2 $3 && dkrrd $1 $2 $4* && dkratt $1'),
|
|
398
440
|
},
|
|
@@ -413,59 +455,36 @@ const ALIASES = {
|
|
|
413
455
|
|
|
414
456
|
// PRIVATE
|
|
415
457
|
'__a-builds-dir': SCRIPT_BACKED_ALIAS(
|
|
416
|
-
|
|
458
|
+
'a-builds-dir', '[PRIVATE]: Return the absolute path to \'.../angular/aio/aio-builds-setup/\'.'),
|
|
417
459
|
},
|
|
418
460
|
|
|
419
461
|
// Env config
|
|
420
462
|
config: {
|
|
421
463
|
// BASH
|
|
422
|
-
cfgbash: new Alias(
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
'use strict';
|
|
427
|
-
const utils = require('../../lib/utils');
|
|
428
|
-
/* eslint-disable max-len */
|
|
429
|
-
console.log(utils.stripIndentation(\`
|
|
430
|
-
### [Generated by: ${VERSION_STAMP}]
|
|
431
|
-
### Copy the following into '~/.bashrc':
|
|
432
|
-
|
|
433
|
-
# Set up prompt.
|
|
434
|
-
PS1='\\\\[\\\\033[90m\\\\][\\\\d \\\\t]\\\\[\\\\033[00m\\\\]\\\\n\\\${debian_chroot:+($debian_chroot)}\\\\[\\\\033[01;32m\\\\]\\\\u@\\\\h\\\\[\\\\033[00m\\\\]:\\\\[\\\\033[01;34m\\\\]\\\\w\\\\[\\\\033[00m\\\\]$ ';
|
|
435
|
-
|
|
436
|
-
# Improve tab completion.
|
|
437
|
-
bind "set completion-ignore-case on";
|
|
438
|
-
bind "set menu-complete-display-prefix on";
|
|
439
|
-
bind "set show-all-if-ambiguous on";
|
|
440
|
-
bind "TAB:menu-complete";
|
|
441
|
-
|
|
442
|
-
\`));
|
|
443
|
-
/* eslint-enable max-len */
|
|
444
|
-
|
|
445
|
-
`),
|
|
446
|
-
/* eslint-enable max-len */
|
|
447
|
-
'Show configuration instructions for `bash`.')),
|
|
464
|
+
cfgbash: new Alias({
|
|
465
|
+
default: CFGBASH_SPEC(false),
|
|
466
|
+
wsl: CFGBASH_SPEC(true),
|
|
467
|
+
}),
|
|
448
468
|
|
|
449
469
|
|
|
450
470
|
// GIT
|
|
451
471
|
cfggit: new Alias({
|
|
452
|
-
default: CFGGIT_SPEC_WITH_CRED_HELPER('
|
|
453
|
-
win32: CFGGIT_SPEC_WITH_CRED_HELPER('manager'),
|
|
472
|
+
default: CFGGIT_SPEC_WITH_CRED_HELPER('manager'),
|
|
454
473
|
wsl: CFGGIT_SPEC_WITH_CRED_HELPER(
|
|
455
|
-
|
|
474
|
+
'/mnt/c/Program\\\\ Files/Git/mingw64/bin/git-credential-manager-core.exe'),
|
|
456
475
|
}),
|
|
457
476
|
|
|
458
477
|
|
|
459
478
|
// VIM
|
|
460
479
|
cfgvim: new Alias(new AliasSpec(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
480
|
+
utils.stripIndentation(`
|
|
481
|
+
#!/usr/bin/env node
|
|
482
|
+
'use strict';
|
|
483
|
+
console.log('""" [Generated by: ${VERSION_STAMP}]');
|
|
484
|
+
console.log('""" Copy the following into \\'~/.vimrc\\':\\n');
|
|
485
|
+
console.log(require('fs').readFileSync(\`\${__dirname}/../../lib/assets/vimrc.txt\`, 'utf8').trim() + '\\n');
|
|
486
|
+
`),
|
|
487
|
+
'Show configuration instructions for `vim`.')),
|
|
469
488
|
},
|
|
470
489
|
|
|
471
490
|
// Misc
|
|
@@ -493,29 +512,29 @@ const ALIASES = {
|
|
|
493
512
|
|
|
494
513
|
// VERSION
|
|
495
514
|
alv: new Alias(new AliasSpec(
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
515
|
+
utils.stripIndentation(`
|
|
516
|
+
#!/usr/bin/env node
|
|
517
|
+
'use strict';
|
|
518
|
+
console.log('${VERSION_STAMP}');
|
|
519
|
+
`),
|
|
520
|
+
`Display the installed version of ${pkg.name}.`)),
|
|
502
521
|
|
|
503
522
|
// HELP
|
|
504
523
|
halp: new Alias(new AliasSpec(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
524
|
+
utils.stripIndentation(`
|
|
525
|
+
#!/usr/bin/env node
|
|
526
|
+
'use strict';
|
|
527
|
+
require('../../lib/helper').help(...process.argv.slice(2));
|
|
528
|
+
`),
|
|
529
|
+
utils.stripIndentation(`
|
|
530
|
+
Display this message. Variations:
|
|
531
|
+
- Pass a category name to list aliases of the specified category only.
|
|
532
|
+
(Example: \`halp node\`)
|
|
533
|
+
- Pass one or more alias names to list only the specified aliases (if they exist).
|
|
534
|
+
(Example: \`halp alv\`)
|
|
535
|
+
- Pass a partial alias name suffixed with \`*\` to list all aliases that start with that value.
|
|
536
|
+
(Example: \`halp grb*\`)
|
|
537
|
+
`))),
|
|
519
538
|
},
|
|
520
539
|
};
|
|
521
540
|
|
package/lib/helper.js
CHANGED
|
@@ -79,8 +79,8 @@ function _help(...names) {
|
|
|
79
79
|
' Does not work with certain types of commands (e.g. `vim`).',
|
|
80
80
|
'',
|
|
81
81
|
utils.wrapLine(
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
'(NOTE: All arguments starting with `--gkcu-` will be ignored when substituting input arguments or ' +
|
|
83
|
+
'determining their index.)'),
|
|
84
84
|
'',
|
|
85
85
|
].join('\n');
|
|
86
86
|
|
package/lib/utils.js
CHANGED
|
@@ -30,8 +30,8 @@ function _capitalize(str) {
|
|
|
30
30
|
|
|
31
31
|
function _finallyAsPromised(promise, callback) {
|
|
32
32
|
return promise.then(
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
val => Promise.resolve(callback()).then(() => val),
|
|
34
|
+
err => Promise.resolve(callback()).then(() => Promise.reject(err)));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function _getPlatform() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gkalpak/aliases",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "My global aliases.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Utility"
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"gd": "./bin/git/gd.js",
|
|
80
80
|
"gd1": "./bin/git/gd1.js",
|
|
81
81
|
"gdn": "./bin/git/gdn.js",
|
|
82
|
+
"gdefb": "./bin/git/gdefb.js",
|
|
82
83
|
"gdn1": "./bin/git/gdn1.js",
|
|
83
84
|
"gdnh": "./bin/git/gdnh.js",
|
|
84
85
|
"gdh": "./bin/git/gdh.js",
|
|
@@ -187,17 +188,17 @@
|
|
|
187
188
|
},
|
|
188
189
|
"dependencies": {
|
|
189
190
|
"@gkalpak/cli-utils": "^0.1.10",
|
|
190
|
-
"chalk": "^4.1.
|
|
191
|
-
"inquirer": "^8.
|
|
191
|
+
"chalk": "^4.1.2",
|
|
192
|
+
"inquirer": "^8.2.4",
|
|
192
193
|
"is-wsl": "^2.2.0"
|
|
193
194
|
},
|
|
194
195
|
"devDependencies": {
|
|
195
|
-
"eslint": "^
|
|
196
|
-
"eslint-plugin-jasmine": "^4.1.
|
|
197
|
-
"jasmine": "^3.
|
|
196
|
+
"eslint": "^8.23.0",
|
|
197
|
+
"eslint-plugin-jasmine": "^4.1.3",
|
|
198
|
+
"jasmine": "^4.3.0",
|
|
198
199
|
"npm-run-all": "^4.1.5",
|
|
199
|
-
"shelljs": "^0.8.
|
|
200
|
-
"strip-ansi": "^6.0.
|
|
200
|
+
"shelljs": "^0.8.5",
|
|
201
|
+
"strip-ansi": "^6.0.1",
|
|
201
202
|
"watch": "^1.0.2"
|
|
202
203
|
}
|
|
203
204
|
}
|
package/scripts/test-pkg.js
CHANGED
|
@@ -46,9 +46,9 @@ function checkFile(propName, filePath, rootDir) {
|
|
|
46
46
|
const missingFile = !existsSync(resolve(rootDir, filePath));
|
|
47
47
|
|
|
48
48
|
reportResults(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
`The file mentioned in \`package.json > ${propName}\` exists.`,
|
|
50
|
+
`The file mentioned in \`package.json > ${propName}\` is missing.`,
|
|
51
|
+
{'Missing script': missingFile ? [filePath] : []});
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function compareToAliases(bin, aliases) {
|
|
@@ -58,12 +58,12 @@ function compareToAliases(bin, aliases) {
|
|
|
58
58
|
const {missing, extra} = diff(expected, actual);
|
|
59
59
|
|
|
60
60
|
reportResults(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
'Aliases in `lib/constants.js` are in-sync with `package.json > bin`.',
|
|
62
|
+
'Aliases in `lib/constants.js` are not in-sync with `package.json > bin`.',
|
|
63
|
+
{
|
|
64
|
+
'Missing from `package.json > bin`': missing,
|
|
65
|
+
'Missing from `lib/constants.js`': extra,
|
|
66
|
+
});
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function compareToBinDir(bin, rootDir) {
|
|
@@ -72,9 +72,9 @@ function compareToBinDir(bin, rootDir) {
|
|
|
72
72
|
filter(path => !existsSync(path));
|
|
73
73
|
|
|
74
74
|
reportResults(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
'All scripts mentioned in `package.json > bin` exist.',
|
|
76
|
+
'Some scripts mentioned in `package.json > bin` are missing.',
|
|
77
|
+
{'Missing scripts': missingScripts});
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
function diff(arr1, arr2) {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
const utils = require('../../lib/utils');
|
|
4
|
-
console.log(utils.stripIndentation(`
|
|
5
|
-
### [Generated by: @gkalpak/aliases v0.9.1]
|
|
6
|
-
### Run the following commands:
|
|
7
|
-
|
|
8
|
-
git config --global core.editor "vim"
|
|
9
|
-
git config --global credential.helper "manager"
|
|
10
|
-
git config --global merge.tool "kdiff3"
|
|
11
|
-
git config --global mergetool.kdiff3.path "/path/to/kdiff3"
|
|
12
|
-
git config --global mergetool.kdiff3.trustExitCode "false"
|
|
13
|
-
git config --global push.default "upstream"
|
|
14
|
-
git config --global rebase.autosquash "true"
|
|
15
|
-
git config --global rebase.autostash "true"
|
|
16
|
-
git config --global user.email "kalpakas.g@gmail.com"
|
|
17
|
-
git config --global user.name "George Kalpakas"
|
|
18
|
-
`));
|