@gkalpak/aliases 0.9.0 → 0.9.3

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 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] >=1.8
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`)
@@ -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.0]
6
+ ### [Generated by: @gkalpak/aliases v0.9.3]
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.3]
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 */
@@ -2,9 +2,10 @@
2
2
  'use strict';
3
3
  const utils = require('../../lib/utils');
4
4
  console.log(utils.stripIndentation(`
5
- ### [Generated by: @gkalpak/aliases v0.9.0]
5
+ ### [Generated by: @gkalpak/aliases v0.9.3]
6
6
  ### Run the following commands:
7
7
 
8
+ git config --global commit.gpgSign true
8
9
  git config --global core.editor "vim"
9
10
  git config --global credential.helper "store"
10
11
  git config --global merge.tool "kdiff3"
@@ -13,6 +14,8 @@ console.log(utils.stripIndentation(`
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
  `));
@@ -2,9 +2,10 @@
2
2
  'use strict';
3
3
  const utils = require('../../lib/utils');
4
4
  console.log(utils.stripIndentation(`
5
- ### [Generated by: @gkalpak/aliases v0.9.0]
5
+ ### [Generated by: @gkalpak/aliases v0.9.3]
6
6
  ### Run the following commands:
7
7
 
8
+ git config --global commit.gpgSign true
8
9
  git config --global core.editor "vim"
9
10
  git config --global credential.helper "manager"
10
11
  git config --global merge.tool "kdiff3"
@@ -13,6 +14,8 @@ console.log(utils.stripIndentation(`
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
  `));
@@ -2,9 +2,10 @@
2
2
  'use strict';
3
3
  const utils = require('../../lib/utils');
4
4
  console.log(utils.stripIndentation(`
5
- ### [Generated by: @gkalpak/aliases v0.9.0]
5
+ ### [Generated by: @gkalpak/aliases v0.9.3]
6
6
  ### Run the following commands:
7
7
 
8
+ git config --global commit.gpgSign true
8
9
  git config --global core.editor "vim"
9
10
  git config --global credential.helper "/mnt/c/Program\\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"
10
11
  git config --global merge.tool "kdiff3"
@@ -13,6 +14,8 @@ console.log(utils.stripIndentation(`
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
  `));
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
- console.log('""" [Generated by: @gkalpak/aliases v0.9.0]');
3
+ console.log('""" [Generated by: @gkalpak/aliases v0.9.3]');
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');
@@ -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:master} && git pull upstream ${1:master} && git push origin ${1:master}';
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,3 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
- console.log('@gkalpak/aliases v0.9.0');
3
+ console.log('@gkalpak/aliases v0.9.3');
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // eslint-disable-next-line max-len
4
+ const cmd = module.exports = 'npm --prefix=$1 install $2*';
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
+ }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // eslint-disable-next-line max-len
4
+ const cmd = module.exports = 'yarn --cwd=$1 install $2*';
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
+ }
@@ -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 master.
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 => (currentBranch === localBranch) && executor.exec('git checkout master')).
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
- `Branch '${branch}' does already exist.\n` +
127
- `Overwrite it? ${chalk.white('[y/N]')} `);
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
- `No GitHub access token found in \`${GH_TOKEN_NAME}\` environment variable.\n` +
282
- 'Proceeding anonymously (and subject to rate-limiting)...');
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('You are supposed to overwrite this method, before creating any instances.');
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
- utils.stripIndentation(`
57
- #!/usr/bin/env node
58
- 'use strict';
59
- const utils = require('../../lib/utils');
60
- console.log(utils.stripIndentation(\`
61
- ### [Generated by: ${VERSION_STAMP}]
62
- ### Run the following commands:
63
-
64
- git config --global core.editor "vim"
65
- git config --global credential.helper "${credHelper}"
66
- git config --global merge.tool "kdiff3"
67
- git config --global mergetool.kdiff3.path "/path/to/kdiff3"
68
- git config --global mergetool.kdiff3.trustExitCode "false"
69
- git config --global push.default "upstream"
70
- git config --global rebase.autosquash "true"
71
- git config --global rebase.autostash "true"
72
- git config --global user.email "kalpakas.g@gmail.com"
73
- git config --global user.name "George Kalpakas"
74
- \`));
75
- `),
76
- 'Show configuration instructions for `git`.');
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('git checkout master $*'),
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
- CLEANUP_CODE('git branches', `${PR_LOCAL_BRANCH_PREFIX}-`, 'git branch', 'git branch --delete --force') +
196
- ' && ' +
197
- CLEANUP_CODE('git remotes', `${PR_REMOTE_ALIAS_PREFIX}-`, 'git remote show', 'git remote remove')),
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
- 'git checkout ${2:HEAD} -b $1 && git config branch.$1.remote origin && git config branch.$1.merge refs/heads/$1'),
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
- 'git checkout master -b $1 && git config branch.$1.remote origin && git config branch.$1.merge refs/heads/$1'),
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('git pull --rebase origin master $*'),
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('git pull --rebase upstream master $*'),
276
+ gprum: new AliasDefault(`git pull --rebase upstream \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} $*`),
238
277
 
239
- // SYNC MASTER
240
- gsync: new AliasDefault('git checkout ${1:master} && git pull upstream ${1:master} && git push origin ${1:master}'),
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('git rebase --ignore-date master $*'),
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,39 +346,41 @@ const ALIASES = {
304
346
  }),
305
347
  nvu: new Alias({
306
348
  default: new AliasSpec(
307
- SCRIPT_BACKED_CODE('nvu', 'nvm use $*'),
308
- `${SOURCE_NVM_CMD} && nvm use $* (it does not affect the currect process)`),
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
- SCRIPT_BACKED_CODE('nvu', 'nvm use $*'),
311
- 'nvm use $* (the 1st arg is replaced with the latest available version on the specified branch)'),
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
- PRINT_NVM_UPDATE_INSTRUCTIONS_CODE(
316
- `${SOURCE_NVM_CMD} && nvm --version`,
317
- 'nvm-sh/nvm',
318
- 'install--update-script',
319
- 'Run: \'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v{{version}}/install.sh | bash\' ' +
320
- '(or \'wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v{{version}}/install.sh | bash\')',
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
- PRINT_NVM_UPDATE_INSTRUCTIONS_CODE(
325
- 'nvm version',
326
- 'coreybutler/nvm-windows',
327
- 'installation--upgrades',
328
- 'Download, unzip and run: ' +
329
- 'https://github.com/coreybutler/nvm-windows/releases/download/{{version}}/nvm-setup.zip',
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
 
334
376
 
335
377
  // INSTALL / UNINSTALL
378
+ niin: new AliasDefault('npm --prefix=$1 install $2*'),
336
379
  nap: new AliasDefault('npm install $* --save'),
337
380
  nad: new AliasDefault('npm install $* --save-dev'),
338
381
  nrp: new AliasDefault('npm remove $* --save'),
339
382
  nrd: new AliasDefault('npm remove $* --save-dev'),
383
+ yiin: new AliasDefault('yarn --cwd=$1 install $2*'),
340
384
  yap: new AliasDefault('yarn add $*'),
341
385
  yad: new AliasDefault('yarn add $* --dev'),
342
386
  yrp: new AliasDefault('yarn remove $*'),
@@ -378,8 +422,8 @@ const ALIASES = {
378
422
  // SPECIAL
379
423
  srv: new AliasDefault('http-server "${1:.}" --port="4000" $2*'),
380
424
  srvw: new AliasDefault(
381
- 'light-server --bind="localhost" --historyindex="/index.html" --serve="${1:.}" --watchexp="${1:.}/**" $2*',
382
- {suppressTbj: true}),
425
+ 'light-server --bind="localhost" --historyindex="/index.html" --serve="${1:.}" --watchexp="${1:.}/**" $2*',
426
+ {suppressTbj: true}),
383
427
  naga: new AliasDefault(`npm install --global ${GLOBAL_NPM_PACKAGES.join(' ')} $*`),
384
428
  yaga: new AliasDefault(`yarn global add ${GLOBAL_NPM_PACKAGES.filter(x => !/^yarn(?:@|$)/.test(x)).join(' ')} $*`),
385
429
  },
@@ -390,7 +434,7 @@ const ALIASES = {
390
434
  dkrrm: new AliasDefault('docker stop $1 & docker rm $1 || true'),
391
435
  dkrbd: new AliasDefault('docker build --tag $1 $3* $2'),
392
436
  dkrrd: new AliasDefault(
393
- 'docker run -d --name $1 -p 4000:4000 -p 4200:4200 -p 4433:4433 -p 8080:8080 -p 9876:9876 $3* $2'),
437
+ 'docker run -d --name $1 -p 4000:4000 -p 4200:4200 -p 4433:4433 -p 8080:8080 -p 9876:9876 $3* $2'),
394
438
  dkratt: new AliasDefault('docker exec -it $1 /bin/bash $2*'),
395
439
  dkrall: new AliasDefault('dkrrm $1 && dkrbd $2 $3 && dkrrd $1 $2 $4* && dkratt $1'),
396
440
  },
@@ -411,38 +455,16 @@ const ALIASES = {
411
455
 
412
456
  // PRIVATE
413
457
  '__a-builds-dir': SCRIPT_BACKED_ALIAS(
414
- 'a-builds-dir', '[PRIVATE]: Return the absolute path to \'.../angular/aio/aio-builds-setup/\'.'),
458
+ 'a-builds-dir', '[PRIVATE]: Return the absolute path to \'.../angular/aio/aio-builds-setup/\'.'),
415
459
  },
416
460
 
417
461
  // Env config
418
462
  config: {
419
463
  // BASH
420
- cfgbash: new Alias(new AliasSpec(
421
- /* eslint-disable max-len */
422
- utils.stripIndentation(`
423
- #!/usr/bin/env node
424
- 'use strict';
425
- const utils = require('../../lib/utils');
426
- /* eslint-disable max-len */
427
- console.log(utils.stripIndentation(\`
428
- ### [Generated by: ${VERSION_STAMP}]
429
- ### Copy the following into '~/.bashrc':
430
-
431
- # Set up prompt.
432
- 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\\\\]$ ';
433
-
434
- # Improve tab completion.
435
- bind "set completion-ignore-case on";
436
- bind "set menu-complete-display-prefix on";
437
- bind "set show-all-if-ambiguous on";
438
- bind "TAB:menu-complete";
439
-
440
- \`));
441
- /* eslint-enable max-len */
442
-
443
- `),
444
- /* eslint-enable max-len */
445
- 'Show configuration instructions for `bash`.')),
464
+ cfgbash: new Alias({
465
+ default: CFGBASH_SPEC(false),
466
+ wsl: CFGBASH_SPEC(true),
467
+ }),
446
468
 
447
469
 
448
470
  // GIT
@@ -450,20 +472,20 @@ const ALIASES = {
450
472
  default: CFGGIT_SPEC_WITH_CRED_HELPER('store'),
451
473
  win32: CFGGIT_SPEC_WITH_CRED_HELPER('manager'),
452
474
  wsl: CFGGIT_SPEC_WITH_CRED_HELPER(
453
- '/mnt/c/Program\\\\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe'),
475
+ '/mnt/c/Program\\\\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe'),
454
476
  }),
455
477
 
456
478
 
457
479
  // VIM
458
480
  cfgvim: new Alias(new AliasSpec(
459
- utils.stripIndentation(`
460
- #!/usr/bin/env node
461
- 'use strict';
462
- console.log('""" [Generated by: ${VERSION_STAMP}]');
463
- console.log('""" Copy the following into \\'~/.vimrc\\':\\n');
464
- console.log(require('fs').readFileSync(\`\${__dirname}/../../lib/assets/vimrc.txt\`, 'utf8').trim() + '\\n');
465
- `),
466
- 'Show configuration instructions for `vim`.')),
481
+ utils.stripIndentation(`
482
+ #!/usr/bin/env node
483
+ 'use strict';
484
+ console.log('""" [Generated by: ${VERSION_STAMP}]');
485
+ console.log('""" Copy the following into \\'~/.vimrc\\':\\n');
486
+ console.log(require('fs').readFileSync(\`\${__dirname}/../../lib/assets/vimrc.txt\`, 'utf8').trim() + '\\n');
487
+ `),
488
+ 'Show configuration instructions for `vim`.')),
467
489
  },
468
490
 
469
491
  // Misc
@@ -491,29 +513,29 @@ const ALIASES = {
491
513
 
492
514
  // VERSION
493
515
  alv: new Alias(new AliasSpec(
494
- utils.stripIndentation(`
495
- #!/usr/bin/env node
496
- 'use strict';
497
- console.log('${VERSION_STAMP}');
498
- `),
499
- `Display the installed version of ${pkg.name}.`)),
516
+ utils.stripIndentation(`
517
+ #!/usr/bin/env node
518
+ 'use strict';
519
+ console.log('${VERSION_STAMP}');
520
+ `),
521
+ `Display the installed version of ${pkg.name}.`)),
500
522
 
501
523
  // HELP
502
524
  halp: new Alias(new AliasSpec(
503
- utils.stripIndentation(`
504
- #!/usr/bin/env node
505
- 'use strict';
506
- require('../../lib/helper').help(...process.argv.slice(2));
507
- `),
508
- utils.stripIndentation(`
509
- Display this message. Variations:
510
- - Pass a category name to list aliases of the specified category only.
511
- (Example: \`halp node\`)
512
- - Pass one or more alias names to list only the specified aliases (if they exist).
513
- (Example: \`halp alv\`)
514
- - Pass a partial alias name suffixed with \`*\` to list all aliases that start with that value.
515
- (Example: \`halp grb*\`)
516
- `))),
525
+ utils.stripIndentation(`
526
+ #!/usr/bin/env node
527
+ 'use strict';
528
+ require('../../lib/helper').help(...process.argv.slice(2));
529
+ `),
530
+ utils.stripIndentation(`
531
+ Display this message. Variations:
532
+ - Pass a category name to list aliases of the specified category only.
533
+ (Example: \`halp node\`)
534
+ - Pass one or more alias names to list only the specified aliases (if they exist).
535
+ (Example: \`halp alv\`)
536
+ - Pass a partial alias name suffixed with \`*\` to list all aliases that start with that value.
537
+ (Example: \`halp grb*\`)
538
+ `))),
517
539
  },
518
540
  };
519
541
 
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
- '(NOTE: All arguments starting with `--gkcu-` will be ignored when substituting input arguments or ' +
83
- 'determining their index.)'),
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
- val => Promise.resolve(callback()).then(() => val),
34
- err => Promise.resolve(callback()).then(() => Promise.reject(err)));
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.0",
3
+ "version": "0.9.3",
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",
@@ -119,6 +120,7 @@
119
120
  "nad": "./bin/node/nad.js",
120
121
  "naga": "./bin/node/naga.js",
121
122
  "nap": "./bin/node/nap.js",
123
+ "niin": "./bin/node/niin.js",
122
124
  "nls": "./bin/node/nls.js",
123
125
  "nls1": "./bin/node/nls1.js",
124
126
  "nlsg": "./bin/node/nlsg.js",
@@ -149,6 +151,7 @@
149
151
  "yad": "./bin/node/yad.js",
150
152
  "yaga": "./bin/node/yaga.js",
151
153
  "yap": "./bin/node/yap.js",
154
+ "yiin": "./bin/node/yiin.js",
152
155
  "yls": "./bin/node/yls.js",
153
156
  "yls1": "./bin/node/yls1.js",
154
157
  "ylsg": "./bin/node/ylsg.js",
@@ -185,17 +188,17 @@
185
188
  },
186
189
  "dependencies": {
187
190
  "@gkalpak/cli-utils": "^0.1.10",
188
- "chalk": "^4.1.1",
189
- "inquirer": "^8.1.2",
191
+ "chalk": "^4.1.2",
192
+ "inquirer": "^8.2.4",
190
193
  "is-wsl": "^2.2.0"
191
194
  },
192
195
  "devDependencies": {
193
- "eslint": "^7.31.0",
194
- "eslint-plugin-jasmine": "^4.1.2",
195
- "jasmine": "^3.8.0",
196
+ "eslint": "^8.23.0",
197
+ "eslint-plugin-jasmine": "^4.1.3",
198
+ "jasmine": "^4.3.0",
196
199
  "npm-run-all": "^4.1.5",
197
- "shelljs": "^0.8.4",
198
- "strip-ansi": "^6.0.0",
200
+ "shelljs": "^0.8.5",
201
+ "strip-ansi": "^6.0.1",
199
202
  "watch": "^1.0.2"
200
203
  }
201
204
  }
@@ -46,9 +46,9 @@ function checkFile(propName, filePath, rootDir) {
46
46
  const missingFile = !existsSync(resolve(rootDir, filePath));
47
47
 
48
48
  reportResults(
49
- `The file mentioned in \`package.json > ${propName}\` exists.`,
50
- `The file mentioned in \`package.json > ${propName}\` is missing.`,
51
- {'Missing script': missingFile ? [filePath] : []});
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
- '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
- });
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
- 'All scripts mentioned in `package.json > bin` exist.',
76
- 'Some scripts mentioned in `package.json > bin` are missing.',
77
- {'Missing scripts': missingScripts});
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) {