@gkalpak/aliases 0.8.17 → 0.9.2
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/bin/config/cfgbash.js +1 -2
- package/bin/config/cfggit.js +1 -1
- package/bin/config/cfggit.win32.js +1 -1
- package/bin/config/cfggit.wsl.js +1 -1
- 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/bin/node/naga.js +1 -1
- package/bin/node/niin.js +11 -0
- package/bin/node/yaga.js +1 -1
- package/bin/node/yiin.js +11 -0
- package/lib/alias-scripts/gcoghpr.js +10 -6
- package/lib/alias.js +2 -1
- package/lib/constants.js +121 -110
- package/lib/helper.js +2 -2
- package/lib/utils.js +2 -2
- package/package.json +11 -8
- package/scripts/test-pkg.js +12 -12
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.
|
|
6
|
+
### [Generated by: @gkalpak/aliases v0.9.2]
|
|
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
|
-
|
package/bin/config/cfggit.js
CHANGED
package/bin/config/cfggit.wsl.js
CHANGED
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.
|
|
3
|
+
console.log('""" [Generated by: @gkalpak/aliases v0.9.2]');
|
|
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
package/bin/node/naga.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 = 'npm install --global @angular/cli @gkalpak/aliases @gkalpak/cli-utils @gkalpak/ng-maintain csslint eslint firebase-tools grunt-cli gulp-cli http-server light-server shx
|
|
4
|
+
const cmd = module.exports = 'npm install --global @angular/cli @gkalpak/aliases @gkalpak/cli-utils @gkalpak/ng-maintain csslint eslint firebase-tools grunt-cli gulp-cli http-server light-server shx typescript typescript-run watch yarn $*';
|
|
5
5
|
if (require.main === module) {
|
|
6
6
|
const {commandUtils} = require('@gkalpak/cli-utils');
|
|
7
7
|
const {onError} = require('../../lib/utils');
|
package/bin/node/niin.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 = '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
|
+
}
|
package/bin/node/yaga.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 = 'yarn global add @angular/cli @gkalpak/aliases @gkalpak/cli-utils @gkalpak/ng-maintain csslint eslint firebase-tools grunt-cli gulp-cli http-server light-server shx
|
|
4
|
+
const cmd = module.exports = 'yarn global add @angular/cli @gkalpak/aliases @gkalpak/cli-utils @gkalpak/ng-maintain csslint eslint firebase-tools grunt-cli gulp-cli http-server light-server shx typescript typescript-run watch $*';
|
|
5
5
|
if (require.main === module) {
|
|
6
6
|
const {commandUtils} = require('@gkalpak/cli-utils');
|
|
7
7
|
const {onError} = require('../../lib/utils');
|
package/bin/node/yiin.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 = '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
|
|
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,7 +12,10 @@ 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
|
|
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';
|
|
18
|
+
const GLOBAL_NPM_PACKAGES = [
|
|
16
19
|
'@angular/cli',
|
|
17
20
|
'@gkalpak/aliases',
|
|
18
21
|
'@gkalpak/cli-utils',
|
|
@@ -25,14 +28,15 @@ const globalNpmPackages = [
|
|
|
25
28
|
'http-server',
|
|
26
29
|
'light-server',
|
|
27
30
|
'shx',
|
|
28
|
-
'ts-node',
|
|
29
31
|
'typescript',
|
|
32
|
+
'typescript-run',
|
|
30
33
|
'watch',
|
|
31
34
|
'yarn',
|
|
32
35
|
];
|
|
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)',
|
|
@@ -53,27 +57,27 @@ const DEF_CODE = AliasSpecDefault.DEF_CODE = (cmd, cfg = {}) => utils.stripInden
|
|
|
53
57
|
`);
|
|
54
58
|
|
|
55
59
|
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
|
-
|
|
60
|
+
utils.stripIndentation(`
|
|
61
|
+
#!/usr/bin/env node
|
|
62
|
+
'use strict';
|
|
63
|
+
const utils = require('../../lib/utils');
|
|
64
|
+
console.log(utils.stripIndentation(\`
|
|
65
|
+
### [Generated by: ${VERSION_STAMP}]
|
|
66
|
+
### Run the following commands:
|
|
67
|
+
|
|
68
|
+
git config --global core.editor "vim"
|
|
69
|
+
git config --global credential.helper "${credHelper}"
|
|
70
|
+
git config --global merge.tool "kdiff3"
|
|
71
|
+
git config --global mergetool.kdiff3.path "/path/to/kdiff3"
|
|
72
|
+
git config --global mergetool.kdiff3.trustExitCode "false"
|
|
73
|
+
git config --global push.default "upstream"
|
|
74
|
+
git config --global rebase.autosquash "true"
|
|
75
|
+
git config --global rebase.autostash "true"
|
|
76
|
+
git config --global user.email "kalpakas.g@gmail.com"
|
|
77
|
+
git config --global user.name "George Kalpakas"
|
|
78
|
+
\`));
|
|
79
|
+
`),
|
|
80
|
+
'Show configuration instructions for `git`.');
|
|
77
81
|
|
|
78
82
|
const SCRIPT_BACKED_CODE = (scriptName, desc) => utils.stripIndentation(`
|
|
79
83
|
#!/usr/bin/env node
|
|
@@ -168,6 +172,7 @@ const ALIASES = {
|
|
|
168
172
|
git: {
|
|
169
173
|
// STATUS
|
|
170
174
|
gs: new AliasDefault('git status $*'),
|
|
175
|
+
gdefb: new AliasDefault(GIT_GET_DEFAULT_BRANCH_CMD),
|
|
171
176
|
gl: new AliasDefault('git log --decorate $* || true'),
|
|
172
177
|
gl1: new AliasDefault('git log --decorate --oneline $* || true'),
|
|
173
178
|
gl1g: new AliasDefault('git log --decorate --oneline | grep $*'),
|
|
@@ -188,13 +193,13 @@ const ALIASES = {
|
|
|
188
193
|
|
|
189
194
|
// CHECKOUT
|
|
190
195
|
gco: new AliasDefault('git checkout ${*:::__g-pick-branch --gkcu-returnOutput=1}'),
|
|
191
|
-
gcom: new AliasDefault(
|
|
196
|
+
gcom: new AliasDefault(`git checkout \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} $*`),
|
|
192
197
|
gcopr: new AliasDefault('git fetch upstream pull/$1/head && git checkout FETCH_HEAD'),
|
|
193
198
|
gcoghpr: SCRIPT_BACKED_ALIAS('gcoghpr', 'Check out a GitHub pull request as a local branch.'),
|
|
194
199
|
'gcoghpr-cleanup': new AliasDefault(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
200
|
+
CLEANUP_CODE('git branches', `${PR_LOCAL_BRANCH_PREFIX}-`, 'git branch', 'git branch --delete --force') +
|
|
201
|
+
' && ' +
|
|
202
|
+
CLEANUP_CODE('git remotes', `${PR_REMOTE_ALIAS_PREFIX}-`, 'git remote show', 'git remote remove')),
|
|
198
203
|
|
|
199
204
|
// ADD / COMMIT
|
|
200
205
|
gaa: new AliasDefault('git add --all $*'),
|
|
@@ -224,25 +229,30 @@ const ALIASES = {
|
|
|
224
229
|
// BRANCH
|
|
225
230
|
gb: new AliasDefault('git branch $*'),
|
|
226
231
|
gbc: new AliasDefault(
|
|
227
|
-
|
|
232
|
+
'git checkout ${2:HEAD} -b $1 && git config branch.$1.remote origin && ' +
|
|
233
|
+
'git config branch.$1.merge refs/heads/$1'),
|
|
228
234
|
gbcm: new AliasDefault(
|
|
229
|
-
|
|
235
|
+
`git checkout \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} -b $1 && git config branch.$1.remote origin && ` +
|
|
236
|
+
'git config branch.$1.merge refs/heads/$1'),
|
|
230
237
|
gbd: new AliasDefault('git branch --delete --force ${*:::__g-pick-branch --gkcu-returnOutput=1}'),
|
|
231
238
|
|
|
232
239
|
// PULL(-REBASE)
|
|
233
240
|
gpr: new AliasDefault('git pull --rebase $*'),
|
|
234
241
|
gpro: new AliasDefault('git pull --rebase origin ${*:::git rev-parse --abbrev-ref HEAD}'),
|
|
235
|
-
gprom: new AliasDefault(
|
|
242
|
+
gprom: new AliasDefault(`git pull --rebase origin \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} $*`),
|
|
236
243
|
gpru: new AliasDefault('git pull --rebase upstream ${*:::git rev-parse --abbrev-ref HEAD}'),
|
|
237
|
-
gprum: new AliasDefault(
|
|
244
|
+
gprum: new AliasDefault(`git pull --rebase upstream \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} $*`),
|
|
238
245
|
|
|
239
|
-
// SYNC
|
|
240
|
-
gsync: new AliasDefault(
|
|
246
|
+
// SYNC DEFAULT BRANCH
|
|
247
|
+
gsync: new AliasDefault(
|
|
248
|
+
`git checkout \${1:::${GIT_GET_DEFAULT_BRANCH_CMD}} && ` +
|
|
249
|
+
`git pull upstream \${1:::${GIT_GET_DEFAULT_BRANCH_CMD}} && ` +
|
|
250
|
+
`git push origin \${1:::${GIT_GET_DEFAULT_BRANCH_CMD}}`),
|
|
241
251
|
|
|
242
252
|
|
|
243
253
|
// REBASE
|
|
244
254
|
grb: new AliasDefault('git rebase ${*:::__g-pick-branch --gkcu-returnOutput=1}'),
|
|
245
|
-
grbm: new AliasDefault(
|
|
255
|
+
grbm: new AliasDefault(`git rebase --ignore-date \${0:::${GIT_GET_DEFAULT_BRANCH_CMD}} $*`),
|
|
246
256
|
grbi: new AliasDefault('git rebase --interactive HEAD~$1'),
|
|
247
257
|
grbia: new AliasDefault('git rebase --autosquash --interactive HEAD~$1'),
|
|
248
258
|
grbin: new AliasDefault('git rebase --no-autosquash --interactive HEAD~$1'),
|
|
@@ -304,39 +314,41 @@ const ALIASES = {
|
|
|
304
314
|
}),
|
|
305
315
|
nvu: new Alias({
|
|
306
316
|
default: new AliasSpec(
|
|
307
|
-
|
|
308
|
-
|
|
317
|
+
SCRIPT_BACKED_CODE('nvu', 'nvm use $*'),
|
|
318
|
+
`${SOURCE_NVM_CMD} && nvm use $* (it does not affect the currect process)`),
|
|
309
319
|
win32: new AliasSpec(
|
|
310
|
-
|
|
311
|
-
|
|
320
|
+
SCRIPT_BACKED_CODE('nvu', 'nvm use $*'),
|
|
321
|
+
'nvm use $* (the 1st arg is replaced with the latest available version on the specified branch)'),
|
|
312
322
|
}),
|
|
313
323
|
nvmup: new Alias({
|
|
314
324
|
default: new AliasSpecDefault(
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
325
|
+
PRINT_NVM_UPDATE_INSTRUCTIONS_CODE(
|
|
326
|
+
`${SOURCE_NVM_CMD} && nvm --version`,
|
|
327
|
+
'nvm-sh/nvm',
|
|
328
|
+
'install--update-script',
|
|
329
|
+
'Run: \'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v{{version}}/install.sh | bash\' ' +
|
|
330
|
+
'(or \'wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v{{version}}/install.sh | bash\')',
|
|
331
|
+
),
|
|
322
332
|
),
|
|
323
333
|
win32: new AliasSpecDefault(
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
334
|
+
PRINT_NVM_UPDATE_INSTRUCTIONS_CODE(
|
|
335
|
+
'nvm version',
|
|
336
|
+
'coreybutler/nvm-windows',
|
|
337
|
+
'installation--upgrades',
|
|
338
|
+
'Download, unzip and run: ' +
|
|
339
|
+
'https://github.com/coreybutler/nvm-windows/releases/download/{{version}}/nvm-setup.zip',
|
|
340
|
+
),
|
|
331
341
|
),
|
|
332
342
|
}),
|
|
333
343
|
|
|
334
344
|
|
|
335
345
|
// INSTALL / UNINSTALL
|
|
346
|
+
niin: new AliasDefault('npm --prefix=$1 install $2*'),
|
|
336
347
|
nap: new AliasDefault('npm install $* --save'),
|
|
337
348
|
nad: new AliasDefault('npm install $* --save-dev'),
|
|
338
349
|
nrp: new AliasDefault('npm remove $* --save'),
|
|
339
350
|
nrd: new AliasDefault('npm remove $* --save-dev'),
|
|
351
|
+
yiin: new AliasDefault('yarn --cwd=$1 install $2*'),
|
|
340
352
|
yap: new AliasDefault('yarn add $*'),
|
|
341
353
|
yad: new AliasDefault('yarn add $* --dev'),
|
|
342
354
|
yrp: new AliasDefault('yarn remove $*'),
|
|
@@ -378,10 +390,10 @@ const ALIASES = {
|
|
|
378
390
|
// SPECIAL
|
|
379
391
|
srv: new AliasDefault('http-server "${1:.}" --port="4000" $2*'),
|
|
380
392
|
srvw: new AliasDefault(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
naga: new AliasDefault(`npm install --global ${
|
|
384
|
-
yaga: new AliasDefault(`yarn global add ${
|
|
393
|
+
'light-server --bind="localhost" --historyindex="/index.html" --serve="${1:.}" --watchexp="${1:.}/**" $2*',
|
|
394
|
+
{suppressTbj: true}),
|
|
395
|
+
naga: new AliasDefault(`npm install --global ${GLOBAL_NPM_PACKAGES.join(' ')} $*`),
|
|
396
|
+
yaga: new AliasDefault(`yarn global add ${GLOBAL_NPM_PACKAGES.filter(x => !/^yarn(?:@|$)/.test(x)).join(' ')} $*`),
|
|
385
397
|
},
|
|
386
398
|
|
|
387
399
|
// Docker
|
|
@@ -390,7 +402,7 @@ const ALIASES = {
|
|
|
390
402
|
dkrrm: new AliasDefault('docker stop $1 & docker rm $1 || true'),
|
|
391
403
|
dkrbd: new AliasDefault('docker build --tag $1 $3* $2'),
|
|
392
404
|
dkrrd: new AliasDefault(
|
|
393
|
-
|
|
405
|
+
'docker run -d --name $1 -p 4000:4000 -p 4200:4200 -p 4433:4433 -p 8080:8080 -p 9876:9876 $3* $2'),
|
|
394
406
|
dkratt: new AliasDefault('docker exec -it $1 /bin/bash $2*'),
|
|
395
407
|
dkrall: new AliasDefault('dkrrm $1 && dkrbd $2 $3 && dkrrd $1 $2 $4* && dkratt $1'),
|
|
396
408
|
},
|
|
@@ -411,38 +423,37 @@ const ALIASES = {
|
|
|
411
423
|
|
|
412
424
|
// PRIVATE
|
|
413
425
|
'__a-builds-dir': SCRIPT_BACKED_ALIAS(
|
|
414
|
-
|
|
426
|
+
'a-builds-dir', '[PRIVATE]: Return the absolute path to \'.../angular/aio/aio-builds-setup/\'.'),
|
|
415
427
|
},
|
|
416
428
|
|
|
417
429
|
// Env config
|
|
418
430
|
config: {
|
|
419
431
|
// BASH
|
|
420
432
|
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
433
|
/* eslint-disable max-len */
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
434
|
+
utils.stripIndentation(`
|
|
435
|
+
#!/usr/bin/env node
|
|
436
|
+
'use strict';
|
|
437
|
+
const utils = require('../../lib/utils');
|
|
438
|
+
/* eslint-disable max-len */
|
|
439
|
+
console.log(utils.stripIndentation(\`
|
|
440
|
+
### [Generated by: ${VERSION_STAMP}]
|
|
441
|
+
### Copy the following into '~/.bashrc':
|
|
442
|
+
|
|
443
|
+
# Set up prompt.
|
|
444
|
+
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\\\\]$ ';
|
|
445
|
+
|
|
446
|
+
# Improve tab completion.
|
|
447
|
+
bind "set completion-ignore-case on";
|
|
448
|
+
bind "set menu-complete-display-prefix on";
|
|
449
|
+
bind "set show-all-if-ambiguous on";
|
|
450
|
+
bind "TAB:menu-complete";
|
|
451
|
+
|
|
452
|
+
\`));
|
|
453
|
+
/* eslint-enable max-len */
|
|
454
|
+
`),
|
|
441
455
|
/* eslint-enable max-len */
|
|
442
|
-
|
|
443
|
-
`),
|
|
444
|
-
/* eslint-enable max-len */
|
|
445
|
-
'Show configuration instructions for `bash`.')),
|
|
456
|
+
'Show configuration instructions for `bash`.')),
|
|
446
457
|
|
|
447
458
|
|
|
448
459
|
// GIT
|
|
@@ -450,20 +461,20 @@ const ALIASES = {
|
|
|
450
461
|
default: CFGGIT_SPEC_WITH_CRED_HELPER('store'),
|
|
451
462
|
win32: CFGGIT_SPEC_WITH_CRED_HELPER('manager'),
|
|
452
463
|
wsl: CFGGIT_SPEC_WITH_CRED_HELPER(
|
|
453
|
-
|
|
464
|
+
'/mnt/c/Program\\\\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe'),
|
|
454
465
|
}),
|
|
455
466
|
|
|
456
467
|
|
|
457
468
|
// VIM
|
|
458
469
|
cfgvim: new Alias(new AliasSpec(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
470
|
+
utils.stripIndentation(`
|
|
471
|
+
#!/usr/bin/env node
|
|
472
|
+
'use strict';
|
|
473
|
+
console.log('""" [Generated by: ${VERSION_STAMP}]');
|
|
474
|
+
console.log('""" Copy the following into \\'~/.vimrc\\':\\n');
|
|
475
|
+
console.log(require('fs').readFileSync(\`\${__dirname}/../../lib/assets/vimrc.txt\`, 'utf8').trim() + '\\n');
|
|
476
|
+
`),
|
|
477
|
+
'Show configuration instructions for `vim`.')),
|
|
467
478
|
},
|
|
468
479
|
|
|
469
480
|
// Misc
|
|
@@ -491,29 +502,29 @@ const ALIASES = {
|
|
|
491
502
|
|
|
492
503
|
// VERSION
|
|
493
504
|
alv: new Alias(new AliasSpec(
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
505
|
+
utils.stripIndentation(`
|
|
506
|
+
#!/usr/bin/env node
|
|
507
|
+
'use strict';
|
|
508
|
+
console.log('${VERSION_STAMP}');
|
|
509
|
+
`),
|
|
510
|
+
`Display the installed version of ${pkg.name}.`)),
|
|
500
511
|
|
|
501
512
|
// HELP
|
|
502
513
|
halp: new Alias(new AliasSpec(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
514
|
+
utils.stripIndentation(`
|
|
515
|
+
#!/usr/bin/env node
|
|
516
|
+
'use strict';
|
|
517
|
+
require('../../lib/helper').help(...process.argv.slice(2));
|
|
518
|
+
`),
|
|
519
|
+
utils.stripIndentation(`
|
|
520
|
+
Display this message. Variations:
|
|
521
|
+
- Pass a category name to list aliases of the specified category only.
|
|
522
|
+
(Example: \`halp node\`)
|
|
523
|
+
- Pass one or more alias names to list only the specified aliases (if they exist).
|
|
524
|
+
(Example: \`halp alv\`)
|
|
525
|
+
- Pass a partial alias name suffixed with \`*\` to list all aliases that start with that value.
|
|
526
|
+
(Example: \`halp grb*\`)
|
|
527
|
+
`))),
|
|
517
528
|
},
|
|
518
529
|
};
|
|
519
530
|
|
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.
|
|
3
|
+
"version": "0.9.2",
|
|
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.
|
|
189
|
-
"inquirer": "^8.1
|
|
191
|
+
"chalk": "^4.1.2",
|
|
192
|
+
"inquirer": "^8.2.1",
|
|
190
193
|
"is-wsl": "^2.2.0"
|
|
191
194
|
},
|
|
192
195
|
"devDependencies": {
|
|
193
|
-
"eslint": "^
|
|
194
|
-
"eslint-plugin-jasmine": "^4.1.
|
|
195
|
-
"jasmine": "^
|
|
196
|
+
"eslint": "^8.11.0",
|
|
197
|
+
"eslint-plugin-jasmine": "^4.1.3",
|
|
198
|
+
"jasmine": "^4.0.2",
|
|
196
199
|
"npm-run-all": "^4.1.5",
|
|
197
|
-
"shelljs": "^0.8.
|
|
198
|
-
"strip-ansi": "^6.0.
|
|
200
|
+
"shelljs": "^0.8.5",
|
|
201
|
+
"strip-ansi": "^6.0.1",
|
|
199
202
|
"watch": "^1.0.2"
|
|
200
203
|
}
|
|
201
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) {
|