@gkalpak/aliases 0.9.4 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/bin/aio/__a-builds-dir.js +5 -7
- package/bin/aio/aioall.js +5 -5
- package/bin/aio/aioatt.js +5 -5
- package/bin/aio/aiobd.js +5 -5
- package/bin/aio/aiord.js +5 -5
- package/bin/aio/aiorm.js +5 -5
- package/bin/config/cfgbash.js +3 -4
- package/bin/config/cfgbash.wsl.js +3 -4
- package/bin/config/cfggit.js +3 -4
- package/bin/config/cfggit.wsl.js +4 -5
- package/bin/config/cfgvim.js +5 -3
- package/bin/docker/dkrall.js +5 -5
- package/bin/docker/dkratt.js +5 -5
- package/bin/docker/dkrbd.js +5 -5
- package/bin/docker/dkrrd.js +5 -5
- package/bin/docker/dkrrm.js +5 -5
- package/bin/git/__g-pick-branch.js +5 -7
- package/bin/git/__g-pick-commit.js +5 -7
- package/bin/git/gaa.js +5 -5
- package/bin/git/gb.js +5 -5
- package/bin/git/gbc.js +5 -5
- package/bin/git/gbcm.js +5 -5
- package/bin/git/gbd.js +5 -5
- package/bin/git/gcl.js +5 -5
- package/bin/git/gcm.js +5 -5
- package/bin/git/gcma.js +5 -5
- package/bin/git/gcmane.js +5 -5
- package/bin/git/gcmf.js +5 -5
- package/bin/git/gcmfc.js +5 -5
- package/bin/git/gcmfs.js +5 -5
- package/bin/git/gcmi.js +5 -5
- package/bin/git/gcmia.js +5 -5
- package/bin/git/gcmiane.js +5 -5
- package/bin/git/gcmif.js +5 -5
- package/bin/git/gcmifc.js +5 -5
- package/bin/git/gcmifs.js +5 -5
- package/bin/git/gco.js +5 -5
- package/bin/git/gcoghpr-cleanup.js +5 -5
- package/bin/git/gcoghpr.js +5 -7
- package/bin/git/gcom.js +5 -5
- package/bin/git/gcopr.js +5 -5
- package/bin/git/gcp.js +5 -5
- package/bin/git/gcpa.js +5 -5
- package/bin/git/gcpc.js +5 -5
- package/bin/git/gcpx.js +5 -5
- package/bin/git/gcpxl.js +5 -5
- package/bin/git/gd.js +5 -5
- package/bin/git/gd1.js +5 -5
- package/bin/git/gdefb.js +5 -5
- package/bin/git/gdh.js +5 -5
- package/bin/git/gdn.js +5 -5
- package/bin/git/gdn1.js +5 -5
- package/bin/git/gdnh.js +5 -5
- package/bin/git/gl.js +5 -5
- package/bin/git/gl1.js +5 -5
- package/bin/git/gl1g.js +5 -5
- package/bin/git/gmt.js +5 -5
- package/bin/git/gngprh.js +5 -5
- package/bin/git/gngprm.js +5 -5
- package/bin/git/gp.js +5 -5
- package/bin/git/gp1.js +5 -5
- package/bin/git/gpf.js +5 -5
- package/bin/git/gpr.js +5 -5
- package/bin/git/gpro.js +5 -5
- package/bin/git/gprom.js +5 -5
- package/bin/git/gpru.js +5 -5
- package/bin/git/gprum.js +5 -5
- package/bin/git/grb.js +5 -5
- package/bin/git/grba.js +5 -5
- package/bin/git/grbc.js +5 -5
- package/bin/git/grbi.js +5 -5
- package/bin/git/grbia.js +5 -5
- package/bin/git/grbin.js +5 -5
- package/bin/git/grbm.js +5 -5
- package/bin/git/grs.js +5 -5
- package/bin/git/grs1.js +5 -5
- package/bin/git/gs.js +5 -5
- package/bin/git/gsh.js +5 -5
- package/bin/git/gshn.js +5 -5
- package/bin/git/gst.js +5 -5
- package/bin/git/gstk.js +5 -5
- package/bin/git/gstl.js +5 -5
- package/bin/git/gstp.js +5 -5
- package/bin/git/gsync.js +5 -5
- package/bin/misc/alv.js +1 -2
- package/bin/misc/halp.js +2 -2
- package/bin/misc/ll.darwin.js +5 -5
- package/bin/misc/ll.js +5 -5
- package/bin/misc/lla.darwin.js +5 -5
- package/bin/misc/lla.js +5 -5
- package/bin/misc/osv.darwin.js +5 -5
- package/bin/misc/osv.js +5 -5
- package/bin/misc/osv.win32.js +5 -5
- package/bin/misc/salfup.js +5 -5
- package/bin/node/nad.js +5 -5
- package/bin/node/naga.js +5 -5
- package/bin/node/nap.js +5 -5
- package/bin/node/niin.js +5 -5
- package/bin/node/nls.js +5 -5
- package/bin/node/nls1.js +5 -5
- package/bin/node/nlsg.js +5 -5
- package/bin/node/nlsg1.js +5 -5
- package/bin/node/nr.js +5 -5
- package/bin/node/nrd.js +5 -5
- package/bin/node/nrin.js +5 -5
- package/bin/node/nrp.js +5 -5
- package/bin/node/nrx.js +5 -5
- package/bin/node/ns.js +5 -5
- package/bin/node/nsin.js +5 -5
- package/bin/node/nsx.js +5 -5
- package/bin/node/nt.js +5 -5
- package/bin/node/ntin.js +5 -5
- package/bin/node/ntx.js +5 -5
- package/bin/node/nua.js +5 -5
- package/bin/node/nud.js +5 -5
- package/bin/node/nup.js +5 -5
- package/bin/node/nv.js +5 -5
- package/bin/node/nvls.js +5 -5
- package/bin/node/nvls.win32.js +5 -5
- package/bin/node/nvlsa.js +5 -5
- package/bin/node/nvlsa.win32.js +5 -5
- package/bin/node/nvmup.js +5 -5
- package/bin/node/nvmup.win32.js +5 -5
- package/bin/node/nvu.js +5 -7
- package/bin/node/srv.js +5 -5
- package/bin/node/srvw.js +5 -5
- package/bin/node/yad.js +5 -5
- package/bin/node/yaga.js +5 -5
- package/bin/node/yap.js +5 -5
- package/bin/node/yiin.js +5 -5
- package/bin/node/yls.js +5 -5
- package/bin/node/yls1.js +5 -5
- package/bin/node/ylsg.js +5 -5
- package/bin/node/ylsg1.js +5 -5
- package/bin/node/yr.js +5 -5
- package/bin/node/yrd.js +5 -5
- package/bin/node/yrin.js +5 -5
- package/bin/node/yrp.js +5 -5
- package/bin/node/yrx.js +5 -5
- package/bin/node/ys.js +5 -5
- package/bin/node/ysin.js +5 -5
- package/bin/node/ysx.js +5 -5
- package/bin/node/yt.js +5 -5
- package/bin/node/ytin.js +5 -5
- package/bin/node/ytx.js +5 -5
- package/bin/node/yua.js +5 -5
- package/bin/node/yud.js +5 -5
- package/bin/node/yup.js +5 -5
- package/lib/alias-scripts/a-builds-dir.js +65 -45
- package/lib/alias-scripts/g-pick-branch.js +44 -25
- package/lib/alias-scripts/g-pick-commit.js +44 -25
- package/lib/alias-scripts/gcoghpr.js +182 -195
- package/lib/alias-scripts/nvu.js +57 -49
- package/lib/alias.js +4 -5
- package/lib/constants.js +68 -47
- package/lib/helper.js +96 -88
- package/lib/utils.js +113 -58
- package/package.json +8 -6
- package/scripts/build.js +11 -10
- package/scripts/platformize-bin.js +7 -7
- package/scripts/test-pkg.js +14 -12
package/bin/node/ysin.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
import {isMain, onError} from '../../lib/utils.js';
|
|
3
4
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {onError} = require('../../lib/utils');
|
|
5
|
+
const cmd = 'yarn --cwd=$1 start $2*';
|
|
6
|
+
export default cmd;
|
|
7
|
+
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
9
9
|
// eslint-disable-next-line quotes
|
|
10
10
|
commandUtils.run(cmd, args, Object.assign({"sapVersion":2}, config)).catch(onError);
|
package/bin/node/ysx.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
import {isMain, onError} from '../../lib/utils.js';
|
|
3
4
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {onError} = require('../../lib/utils');
|
|
5
|
+
const cmd = 'yarn start $*';
|
|
6
|
+
export default cmd;
|
|
7
|
+
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
9
9
|
// eslint-disable-next-line quotes
|
|
10
10
|
commandUtils.run(cmd, args, Object.assign({"sapVersion":2,"suppressTbj":true}, config)).catch(onError);
|
package/bin/node/yt.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
import {isMain, onError} from '../../lib/utils.js';
|
|
3
4
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {onError} = require('../../lib/utils');
|
|
5
|
+
const cmd = 'yarn test $*';
|
|
6
|
+
export default cmd;
|
|
7
|
+
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
9
9
|
// eslint-disable-next-line quotes
|
|
10
10
|
commandUtils.run(cmd, args, Object.assign({"sapVersion":2}, config)).catch(onError);
|
package/bin/node/ytin.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
import {isMain, onError} from '../../lib/utils.js';
|
|
3
4
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {onError} = require('../../lib/utils');
|
|
5
|
+
const cmd = 'yarn --cwd=$1 test $2*';
|
|
6
|
+
export default cmd;
|
|
7
|
+
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
9
9
|
// eslint-disable-next-line quotes
|
|
10
10
|
commandUtils.run(cmd, args, Object.assign({"sapVersion":2}, config)).catch(onError);
|
package/bin/node/ytx.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
import {isMain, onError} from '../../lib/utils.js';
|
|
3
4
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {onError} = require('../../lib/utils');
|
|
5
|
+
const cmd = 'yarn test $*';
|
|
6
|
+
export default cmd;
|
|
7
|
+
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
9
9
|
// eslint-disable-next-line quotes
|
|
10
10
|
commandUtils.run(cmd, args, Object.assign({"sapVersion":2,"suppressTbj":true}, config)).catch(onError);
|
package/bin/node/yua.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
import {isMain, onError} from '../../lib/utils.js';
|
|
3
4
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {onError} = require('../../lib/utils');
|
|
5
|
+
const cmd = 'node --eval "/* Update dependencies. */ const deps = Object.keys(require(\'./package.json\').dependencies || {}).map(x => x + \'@latest\'); console.log(\'\\nUpdating \' + deps.length + \' dependencies...\'); deps.length && child_process.spawnSync(\'yap\', deps, {shell: true, stdio: \'inherit\'});" && node --eval "/* Update devDependencies. */ const deps = Object.keys(require(\'./package.json\').devDependencies || {}).map(x => x + \'@latest\'); console.log(\'\\nUpdating \' + deps.length + \' devDependencies...\'); deps.length && child_process.spawnSync(\'yad\', deps, {shell: true, stdio: \'inherit\'});"';
|
|
6
|
+
export default cmd;
|
|
7
|
+
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
9
9
|
// eslint-disable-next-line quotes
|
|
10
10
|
commandUtils.run(cmd, args, Object.assign({"sapVersion":2}, config)).catch(onError);
|
package/bin/node/yud.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
import {isMain, onError} from '../../lib/utils.js';
|
|
3
4
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {onError} = require('../../lib/utils');
|
|
5
|
+
const cmd = 'node --eval "/* Update devDependencies. */ const deps = Object.keys(require(\'./package.json\').devDependencies || {}).map(x => x + \'@latest\'); console.log(\'\\nUpdating \' + deps.length + \' devDependencies...\'); deps.length && child_process.spawnSync(\'yad\', deps, {shell: true, stdio: \'inherit\'});"';
|
|
6
|
+
export default cmd;
|
|
7
|
+
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
9
9
|
// eslint-disable-next-line quotes
|
|
10
10
|
commandUtils.run(cmd, args, Object.assign({"sapVersion":2}, config)).catch(onError);
|
package/bin/node/yup.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
import {isMain, onError} from '../../lib/utils.js';
|
|
3
4
|
// eslint-disable-next-line max-len
|
|
4
|
-
const cmd =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const {onError} = require('../../lib/utils');
|
|
5
|
+
const cmd = 'node --eval "/* Update dependencies. */ const deps = Object.keys(require(\'./package.json\').dependencies || {}).map(x => x + \'@latest\'); console.log(\'\\nUpdating \' + deps.length + \' dependencies...\'); deps.length && child_process.spawnSync(\'yap\', deps, {shell: true, stdio: \'inherit\'});"';
|
|
6
|
+
export default cmd;
|
|
7
|
+
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
9
9
|
// eslint-disable-next-line quotes
|
|
10
10
|
commandUtils.run(cmd, args, Object.assign({"sapVersion":2}, config)).catch(onError);
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
// Imports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import {stat} from 'node:fs/promises';
|
|
3
|
+
import {resolve as pathResolve} from 'node:path';
|
|
4
|
+
|
|
5
|
+
import {stripIndentation} from '../utils.js';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// Constants
|
|
9
|
+
const internal = {
|
|
10
|
+
_aBuildsDir,
|
|
11
|
+
_fsStat,
|
|
12
|
+
_pathResolve,
|
|
13
|
+
};
|
|
7
14
|
|
|
8
15
|
// Exports
|
|
9
|
-
|
|
16
|
+
export {
|
|
10
17
|
/**
|
|
11
18
|
* @function aBuildsDir
|
|
12
19
|
*
|
|
@@ -19,44 +26,49 @@ const exps = module.exports = {
|
|
|
19
26
|
* @return {Promise<void|string>} - A promise that resolves to either `undefined` or the absolute directory path
|
|
20
27
|
* (depending on the value of `config.returnOutput`).
|
|
21
28
|
*/
|
|
22
|
-
aBuildsDir
|
|
29
|
+
aBuildsDir,
|
|
23
30
|
|
|
24
|
-
main
|
|
25
|
-
};
|
|
31
|
+
main,
|
|
26
32
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
33
|
+
// Exposed for testing purposes only.
|
|
34
|
+
internal as _testing,
|
|
35
|
+
};
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
// Helpers
|
|
38
|
+
async function _aBuildsDir(config) {
|
|
33
39
|
if (config.dryrun) {
|
|
34
40
|
console.log('Get the absolute path to \'.../angular/aio/aio-builds-setup/\'.');
|
|
35
|
-
return
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const buildsDirPath = await locateBuildsDir(config.debug);
|
|
45
|
+
|
|
46
|
+
if (config.returnOutput) {
|
|
47
|
+
return buildsDirPath;
|
|
36
48
|
}
|
|
37
49
|
|
|
38
|
-
|
|
39
|
-
then(buildsDirPath => config.returnOutput ? buildsDirPath : console.log(buildsDirPath));
|
|
50
|
+
console.log(buildsDirPath);
|
|
40
51
|
}
|
|
41
52
|
|
|
42
|
-
function
|
|
43
|
-
return
|
|
53
|
+
function _fsStat(filePath) {
|
|
54
|
+
return stat(filePath);
|
|
44
55
|
}
|
|
45
56
|
|
|
46
|
-
function
|
|
47
|
-
return
|
|
48
|
-
then(prev => prev && /[\\/]aio[\\/]aio-builds-setup$/.test(candidateAbsPath)).
|
|
49
|
-
then(prev => prev && exists(candidateAbsPath)).
|
|
50
|
-
then(prev => prev && isDirectory(candidateAbsPath));
|
|
57
|
+
function _pathResolve(...paths) {
|
|
58
|
+
return pathResolve(...paths);
|
|
51
59
|
}
|
|
52
60
|
|
|
53
|
-
function
|
|
54
|
-
return
|
|
55
|
-
fs.stat(somePath, (err, stats) =>
|
|
56
|
-
err ? reject(err) : resolve(stats.isDirectory())));
|
|
61
|
+
function aBuildsDir(config) {
|
|
62
|
+
return internal._aBuildsDir(config);
|
|
57
63
|
}
|
|
58
64
|
|
|
59
|
-
function
|
|
65
|
+
async function isBuildsDir(candidateAbsPath) {
|
|
66
|
+
return /[\\/]aio[\\/]aio-builds-setup$/.test(candidateAbsPath) &&
|
|
67
|
+
await pathExists(candidateAbsPath) &&
|
|
68
|
+
await pathIsDirectory(candidateAbsPath);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function locateBuildsDir(debug = false) {
|
|
60
72
|
const candidateRelPaths = [
|
|
61
73
|
'aio/aio-builds-setup', // Run from: angular/
|
|
62
74
|
'aio-builds-setup', // Run from: angular/aio/
|
|
@@ -65,29 +77,37 @@ function locateBuildsDir(debug = false) {
|
|
|
65
77
|
'../..', // Run from: angular/aio/aio-builds-setup/dockerbuild/scripts-js/
|
|
66
78
|
];
|
|
67
79
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (prevAbsPath) return prevAbsPath;
|
|
80
|
+
for (const p of candidateRelPaths) {
|
|
81
|
+
const absPath = internal._pathResolve(p);
|
|
71
82
|
|
|
72
|
-
|
|
83
|
+
if (debug) {
|
|
84
|
+
console.log(`Checking '${p}' (resolved to '${absPath}')...`);
|
|
85
|
+
}
|
|
73
86
|
|
|
87
|
+
if (await isBuildsDir(absPath)) {
|
|
74
88
|
if (debug) {
|
|
75
|
-
console.log(`
|
|
89
|
+
console.log(`Target directory found: ${absPath}`);
|
|
76
90
|
}
|
|
77
91
|
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (debug && buildsDirPath) {
|
|
82
|
-
console.log(`Target directory found: ${buildsDirPath}`);
|
|
83
|
-
}
|
|
84
|
-
return buildsDirPath || notFound();
|
|
85
|
-
});
|
|
86
|
-
}
|
|
92
|
+
return absPath;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
throw new Error(utils.stripIndentation(`
|
|
96
|
+
throw new Error(stripIndentation(`
|
|
90
97
|
Unable to locate the '.../aio/aio-setup-builds/' directory.
|
|
91
98
|
Make sure you are in a directory between 'angular/' and 'angular/aio/aio-builds-setup/dockerbuild/scripts-js/'.
|
|
92
99
|
`));
|
|
93
100
|
}
|
|
101
|
+
|
|
102
|
+
function main(_runtimeArgs, config) {
|
|
103
|
+
return aBuildsDir(config);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function pathExists(somePath) {
|
|
107
|
+
return internal._fsStat(somePath).then(() => true, () => false);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function pathIsDirectory(somePath) {
|
|
111
|
+
const stats = await internal._fsStat(somePath);
|
|
112
|
+
return stats.isDirectory();
|
|
113
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
// Imports
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {commandUtils, processUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
|
|
4
|
+
import {importWithEnv} from '../utils.js';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
// Constants
|
|
8
|
+
const internal = {
|
|
9
|
+
_gPickBranch,
|
|
10
|
+
};
|
|
9
11
|
|
|
10
12
|
// Exports
|
|
11
|
-
|
|
13
|
+
export {
|
|
12
14
|
/**
|
|
13
15
|
* @function gPickBranch
|
|
14
16
|
*
|
|
@@ -20,30 +22,45 @@ const exps = module.exports = {
|
|
|
20
22
|
* @return {Promise<void|string>} - A promise that resolves to either `undefined` or the selected branch (depending on
|
|
21
23
|
* the value of `config.returnOutput`).
|
|
22
24
|
*/
|
|
23
|
-
gPickBranch
|
|
25
|
+
gPickBranch,
|
|
24
26
|
|
|
25
|
-
main
|
|
26
|
-
};
|
|
27
|
+
main,
|
|
27
28
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
29
|
+
// Exposed for testing purposes only.
|
|
30
|
+
internal as _testing,
|
|
31
|
+
};
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
// Helpers
|
|
34
|
+
async function _gPickBranch(config) {
|
|
34
35
|
const gbConfig = Object.assign({}, config, {returnOutput: true});
|
|
35
36
|
|
|
36
37
|
if (config.dryrun) {
|
|
37
38
|
console.log('Pick one from a list of branches.');
|
|
38
|
-
return
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const branchOutput = await commandUtils.run('git branch', [], gbConfig);
|
|
43
|
+
const branch = await pickBranch(branchOutput);
|
|
44
|
+
|
|
45
|
+
if (config.returnOutput) {
|
|
46
|
+
return branch;
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
console.log(branch);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function gPickBranch(config) {
|
|
53
|
+
return internal._gPickBranch(config);
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
function
|
|
56
|
+
function main(_runtimeArgs, config) {
|
|
57
|
+
return gPickBranch(config);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function pickBranch(branchesStr) {
|
|
61
|
+
// Ensure colors are always used (even when running with `returnOutput: <number>`).
|
|
62
|
+
const {default: inquirer} = await importWithEnv('inquirer', import.meta.url, {FORCE_COLOR: '1'});
|
|
63
|
+
|
|
47
64
|
let currentBranchIdx = 0;
|
|
48
65
|
const branches = branchesStr.
|
|
49
66
|
split('\n').
|
|
@@ -85,8 +102,8 @@ function pickBranch(branchesStr) {
|
|
|
85
102
|
}
|
|
86
103
|
});
|
|
87
104
|
|
|
88
|
-
|
|
89
|
-
prompt([
|
|
105
|
+
try {
|
|
106
|
+
const {branch} = await inquirer.prompt([
|
|
90
107
|
{
|
|
91
108
|
type: 'list',
|
|
92
109
|
name: 'branch',
|
|
@@ -94,8 +111,10 @@ function pickBranch(branchesStr) {
|
|
|
94
111
|
choices: branches,
|
|
95
112
|
default: currentBranchIdx,
|
|
96
113
|
},
|
|
97
|
-
])
|
|
98
|
-
then(({branch}) => branch);
|
|
114
|
+
]);
|
|
99
115
|
|
|
100
|
-
|
|
116
|
+
return branch;
|
|
117
|
+
} finally {
|
|
118
|
+
unlisten();
|
|
119
|
+
}
|
|
101
120
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
// Imports
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {commandUtils, processUtils} from '@gkalpak/cli-utils';
|
|
3
|
+
|
|
4
|
+
import {importWithEnv} from '../utils.js';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
// Constants
|
|
8
|
+
const internal = {
|
|
9
|
+
_gPickCommit,
|
|
10
|
+
};
|
|
9
11
|
|
|
10
12
|
// Exports
|
|
11
|
-
|
|
13
|
+
export {
|
|
12
14
|
/**
|
|
13
15
|
* @function gPickCommit
|
|
14
16
|
*
|
|
@@ -20,30 +22,45 @@ const exps = module.exports = {
|
|
|
20
22
|
* @return {Promise<void|string>} - A promise that resolves to either `undefined` or the selected commit (depending on
|
|
21
23
|
* the value of `config.returnOutput`).
|
|
22
24
|
*/
|
|
23
|
-
gPickCommit
|
|
25
|
+
gPickCommit,
|
|
24
26
|
|
|
25
|
-
main
|
|
26
|
-
};
|
|
27
|
+
main,
|
|
27
28
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
29
|
+
// Exposed for testing purposes only.
|
|
30
|
+
internal as _testing,
|
|
31
|
+
};
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
// Helpers
|
|
34
|
+
async function _gPickCommit(config) {
|
|
34
35
|
const glConfig = Object.assign({}, config, {returnOutput: true});
|
|
35
36
|
|
|
36
37
|
if (config.dryrun) {
|
|
37
38
|
console.log('Pick one from a list of commits.');
|
|
38
|
-
return
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const commitOutput = await commandUtils.run('git log --oneline -50', [], glConfig);
|
|
43
|
+
const commit = await pickCommit(commitOutput);
|
|
44
|
+
|
|
45
|
+
if (config.returnOutput) {
|
|
46
|
+
return commit;
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
console.log(commit);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function gPickCommit(config) {
|
|
53
|
+
return internal._gPickCommit(config);
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
function
|
|
56
|
+
function main(_runtimeArgs, config) {
|
|
57
|
+
return gPickCommit(config);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function pickCommit(commitsStr) {
|
|
61
|
+
// Ensure colors are always used (even when running with `returnOutput: <number>`).
|
|
62
|
+
const {default: inquirer} = await importWithEnv('inquirer', import.meta.url, {FORCE_COLOR: '1'});
|
|
63
|
+
|
|
47
64
|
const commits = commitsStr.
|
|
48
65
|
split('\n').
|
|
49
66
|
map(line => line.trim()).
|
|
@@ -59,8 +76,8 @@ function pickCommit(commitsStr) {
|
|
|
59
76
|
}
|
|
60
77
|
});
|
|
61
78
|
|
|
62
|
-
|
|
63
|
-
prompt([
|
|
79
|
+
try {
|
|
80
|
+
const {commit} = await inquirer.prompt([
|
|
64
81
|
{
|
|
65
82
|
type: 'list',
|
|
66
83
|
name: 'commit',
|
|
@@ -68,8 +85,10 @@ function pickCommit(commitsStr) {
|
|
|
68
85
|
choices: commits,
|
|
69
86
|
default: 0,
|
|
70
87
|
},
|
|
71
|
-
])
|
|
72
|
-
then(({commit}) => commit.replace(/\s+.*$/, ''));
|
|
88
|
+
]);
|
|
73
89
|
|
|
74
|
-
|
|
90
|
+
return commit.replace(/\s+.*$/, '');
|
|
91
|
+
} finally {
|
|
92
|
+
unlisten();
|
|
93
|
+
}
|
|
75
94
|
}
|