@gkalpak/aliases 0.13.7 → 0.14.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 +1 -1
- package/bin/config/cfgbash.js +1 -1
- package/bin/config/cfgbash.wsl.js +1 -1
- 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/cfggpg.js +1 -1
- package/bin/config/cfgssh.js +1 -1
- package/bin/config/cfgvim.js +1 -1
- package/bin/config/cfgwsl.wsl.js +2 -2
- package/bin/misc/alv.js +1 -1
- package/bin/node/nua.js +1 -1
- package/bin/node/nud.js +1 -1
- package/bin/node/nup.js +1 -1
- package/bin/node/yua.js +1 -1
- package/bin/node/yud.js +1 -1
- package/bin/node/yup.js +1 -1
- package/lib/alias-scripts/g-pick-branch.js +16 -10
- package/lib/alias-scripts/g-pick-commit.js +20 -13
- package/lib/constants.js +4 -2
- package/lib/utils.js +21 -16
- package/package.json +8 -18
- package/scripts/platformize-bin.js +9 -12
- package/scripts/run-npm-script.js +8 -0
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ Here is the list of all global dependencies with associated min. version (older
|
|
|
68
68
|
- `ls`: [ls] >=8 (could come through a bash emulation environment on Windows, such as [git for Windows][git-win]' `Git BASH`)
|
|
69
69
|
- `ngm-diff-wh`: `ngm-diff-wh` >=0.0.4 (part of the [ng-maintain] suite)
|
|
70
70
|
- `ngm-pr-merge`: `ngm-pr-merge` >=0.0.4 (part of the [ng-maintain] suite)
|
|
71
|
-
- `node`: [Node.js][node] >=
|
|
71
|
+
- `node`: [Node.js][node] >=20
|
|
72
72
|
- `npm`: [npm] >=3 (comes bundled with Node.js)
|
|
73
73
|
- `nvm`: [nvm] >=0.30 (on *nix) / [nvm-windows][nvm-win] >=1 (on Windows)
|
|
74
74
|
- `yarn`: [yarn] >=0.24
|
package/bin/config/cfgbash.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
/* eslint-disable max-len */
|
|
4
4
|
console.log(stripIndentation(`
|
|
5
|
-
### [Generated by: @gkalpak/aliases v0.
|
|
5
|
+
### [Generated by: @gkalpak/aliases v0.14.1]
|
|
6
6
|
### Copy the following into '~/.bashrc':
|
|
7
7
|
|
|
8
8
|
# Set up prompt.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
/* eslint-disable max-len */
|
|
4
4
|
console.log(stripIndentation(`
|
|
5
|
-
### [Generated by: @gkalpak/aliases v0.
|
|
5
|
+
### [Generated by: @gkalpak/aliases v0.14.1]
|
|
6
6
|
### Copy the following into '~/.bashrc':
|
|
7
7
|
|
|
8
8
|
# Set up prompt.
|
package/bin/config/cfggit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
console.log(stripIndentation(`
|
|
4
|
-
### [Generated by: @gkalpak/aliases v0.
|
|
4
|
+
### [Generated by: @gkalpak/aliases v0.14.1]
|
|
5
5
|
### Run the following commands:
|
|
6
6
|
|
|
7
7
|
git config --global commit.gpgSign "true"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
console.log(stripIndentation(`
|
|
4
|
-
### [Generated by: @gkalpak/aliases v0.
|
|
4
|
+
### [Generated by: @gkalpak/aliases v0.14.1]
|
|
5
5
|
### Run the following commands:
|
|
6
6
|
|
|
7
7
|
git config --global commit.gpgSign "true"
|
package/bin/config/cfggit.wsl.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
console.log(stripIndentation(`
|
|
4
|
-
### [Generated by: @gkalpak/aliases v0.
|
|
4
|
+
### [Generated by: @gkalpak/aliases v0.14.1]
|
|
5
5
|
### Run the following commands:
|
|
6
6
|
|
|
7
7
|
git config --global commit.gpgSign "true"
|
package/bin/config/cfggpg.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
console.log(stripIndentation(`
|
|
4
|
-
### [Generated by: @gkalpak/aliases v0.
|
|
4
|
+
### [Generated by: @gkalpak/aliases v0.14.1]
|
|
5
5
|
### Copy the following into '~/.gnupg/gpg-agent.conf':
|
|
6
6
|
|
|
7
7
|
default-cache-ttl 86400
|
package/bin/config/cfgssh.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
console.log(stripIndentation(`
|
|
4
|
-
### [Generated by: @gkalpak/aliases v0.
|
|
4
|
+
### [Generated by: @gkalpak/aliases v0.14.1]
|
|
5
5
|
### Copy the following into '~/.ssh/config':
|
|
6
6
|
|
|
7
7
|
IdentityFile ~/.ssh/id-rsa-gkalpak.priv
|
package/bin/config/cfgvim.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
import {readFileSync} from 'node:fs';
|
|
3
3
|
import {fileURLToPath} from 'node:url';
|
|
4
4
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
5
|
-
console.log('""" [Generated by: @gkalpak/aliases v0.
|
|
5
|
+
console.log('""" [Generated by: @gkalpak/aliases v0.14.1]');
|
|
6
6
|
console.log('""" Copy the following into \'~/.vimrc\':\n');
|
|
7
7
|
console.log(readFileSync(`${__dirname}/../../lib/assets/vimrc.txt`, 'utf8').trim() + '\n');
|
package/bin/config/cfgwsl.wsl.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {stripIndentation} from '../../lib/utils.js';
|
|
3
3
|
console.log(stripIndentation(`
|
|
4
|
-
### [Generated by: @gkalpak/aliases v0.
|
|
4
|
+
### [Generated by: @gkalpak/aliases v0.14.1]
|
|
5
5
|
### Copy the following into a root-owned, 600-mode '/etc/resolv.conf' file:
|
|
6
6
|
|
|
7
7
|
# Cloudflare
|
|
@@ -14,7 +14,7 @@ console.log(stripIndentation(`
|
|
|
14
14
|
|
|
15
15
|
-----
|
|
16
16
|
|
|
17
|
-
### [Generated by: @gkalpak/aliases v0.
|
|
17
|
+
### [Generated by: @gkalpak/aliases v0.14.1]
|
|
18
18
|
### Copy the following into a root-owned, 600-mode '/etc/wsl.conf' file:
|
|
19
19
|
|
|
20
20
|
[network]
|
package/bin/misc/alv.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
console.log('@gkalpak/aliases v0.
|
|
2
|
+
console.log('@gkalpak/aliases v0.14.1');
|
package/bin/node/nua.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
3
|
import {isMain, onError} from '../../lib/utils.js';
|
|
4
4
|
// eslint-disable-next-line max-len
|
|
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.
|
|
5
|
+
const cmd = 'node --eval "/* Update dependencies. */ const deps = Object.keys(require(\'./package.json\').dependencies || {}).map(x => x + \'@latest\'); const cmd = \'nap \' + deps.join(\' \'); console.log(\'\\nUpdating \' + deps.length + \' dependencies...\'); console.log(\' Command: \' + cmd); deps.length && child_process.execSync(cmd, {shell: true, stdio: \'inherit\'});" && node --eval "/* Update devDependencies. */ const deps = Object.keys(require(\'./package.json\').devDependencies || {}).map(x => x + \'@latest\'); const cmd = \'nad \' + deps.join(\' \'); console.log(\'\\nUpdating \' + deps.length + \' devDependencies...\'); console.log(\' Command: \' + cmd); deps.length && child_process.execSync(cmd, {shell: true, stdio: \'inherit\'});"';
|
|
6
6
|
export default cmd;
|
|
7
7
|
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
package/bin/node/nud.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
3
|
import {isMain, onError} from '../../lib/utils.js';
|
|
4
4
|
// eslint-disable-next-line max-len
|
|
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.
|
|
5
|
+
const cmd = 'node --eval "/* Update devDependencies. */ const deps = Object.keys(require(\'./package.json\').devDependencies || {}).map(x => x + \'@latest\'); const cmd = \'nad \' + deps.join(\' \'); console.log(\'\\nUpdating \' + deps.length + \' devDependencies...\'); console.log(\' Command: \' + cmd); deps.length && child_process.execSync(cmd, {shell: true, stdio: \'inherit\'});"';
|
|
6
6
|
export default cmd;
|
|
7
7
|
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
package/bin/node/nup.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
3
|
import {isMain, onError} from '../../lib/utils.js';
|
|
4
4
|
// eslint-disable-next-line max-len
|
|
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.
|
|
5
|
+
const cmd = 'node --eval "/* Update dependencies. */ const deps = Object.keys(require(\'./package.json\').dependencies || {}).map(x => x + \'@latest\'); const cmd = \'nap \' + deps.join(\' \'); console.log(\'\\nUpdating \' + deps.length + \' dependencies...\'); console.log(\' Command: \' + cmd); deps.length && child_process.execSync(cmd, {shell: true, stdio: \'inherit\'});"';
|
|
6
6
|
export default cmd;
|
|
7
7
|
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
package/bin/node/yua.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
3
|
import {isMain, onError} from '../../lib/utils.js';
|
|
4
4
|
// eslint-disable-next-line max-len
|
|
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.
|
|
5
|
+
const cmd = 'node --eval "/* Update dependencies. */ const deps = Object.keys(require(\'./package.json\').dependencies || {}).map(x => x + \'@latest\'); const cmd = \'yap \' + deps.join(\' \'); console.log(\'\\nUpdating \' + deps.length + \' dependencies...\'); console.log(\' Command: \' + cmd); deps.length && child_process.execSync(cmd, {shell: true, stdio: \'inherit\'});" && node --eval "/* Update devDependencies. */ const deps = Object.keys(require(\'./package.json\').devDependencies || {}).map(x => x + \'@latest\'); const cmd = \'yad \' + deps.join(\' \'); console.log(\'\\nUpdating \' + deps.length + \' devDependencies...\'); console.log(\' Command: \' + cmd); deps.length && child_process.execSync(cmd, {shell: true, stdio: \'inherit\'});"';
|
|
6
6
|
export default cmd;
|
|
7
7
|
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
package/bin/node/yud.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
3
|
import {isMain, onError} from '../../lib/utils.js';
|
|
4
4
|
// eslint-disable-next-line max-len
|
|
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.
|
|
5
|
+
const cmd = 'node --eval "/* Update devDependencies. */ const deps = Object.keys(require(\'./package.json\').devDependencies || {}).map(x => x + \'@latest\'); const cmd = \'yad \' + deps.join(\' \'); console.log(\'\\nUpdating \' + deps.length + \' devDependencies...\'); console.log(\' Command: \' + cmd); deps.length && child_process.execSync(cmd, {shell: true, stdio: \'inherit\'});"';
|
|
6
6
|
export default cmd;
|
|
7
7
|
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
package/bin/node/yup.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {commandUtils} from '@gkalpak/cli-utils';
|
|
3
3
|
import {isMain, onError} from '../../lib/utils.js';
|
|
4
4
|
// eslint-disable-next-line max-len
|
|
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.
|
|
5
|
+
const cmd = 'node --eval "/* Update dependencies. */ const deps = Object.keys(require(\'./package.json\').dependencies || {}).map(x => x + \'@latest\'); const cmd = \'yap \' + deps.join(\' \'); console.log(\'\\nUpdating \' + deps.length + \' dependencies...\'); console.log(\' Command: \' + cmd); deps.length && child_process.execSync(cmd, {shell: true, stdio: \'inherit\'});"';
|
|
6
6
|
export default cmd;
|
|
7
7
|
if (isMain(import.meta.url)) {
|
|
8
8
|
const {args, config} = commandUtils.preprocessArgs(process.argv.slice(2));
|
|
@@ -70,7 +70,7 @@ function main(runtimeArgs, config) {
|
|
|
70
70
|
|
|
71
71
|
async function pickBranch(branchType, branches) {
|
|
72
72
|
// Ensure colors are always used (even when running with `returnOutput: <number>`).
|
|
73
|
-
const {default:
|
|
73
|
+
const {default: select, Separator} = await importWithEnv(() => import('@inquirer/select'), {FORCE_COLOR: '1'});
|
|
74
74
|
|
|
75
75
|
const currentBranchIdx = Math.max(0, branches.findIndex(({name}) => name.endsWith(branchNameSuffices['*'])));
|
|
76
76
|
|
|
@@ -84,17 +84,23 @@ async function pickBranch(branchType, branches) {
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
try {
|
|
87
|
-
const
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
choices: branches.concat(new inquirer.Separator()),
|
|
93
|
-
default: currentBranchIdx,
|
|
94
|
-
},
|
|
95
|
-
]);
|
|
87
|
+
const branch = await select({
|
|
88
|
+
message: `Pick a ${branchType} branch:`,
|
|
89
|
+
choices: branches.concat(new Separator()),
|
|
90
|
+
default: branches[currentBranchIdx]?.value,
|
|
91
|
+
});
|
|
96
92
|
|
|
97
93
|
return branch;
|
|
94
|
+
} catch (err) {
|
|
95
|
+
if (
|
|
96
|
+
(err instanceof Error) &&
|
|
97
|
+
(err.name === 'ExitPromptError') &&
|
|
98
|
+
err.message.startsWith('User force closed the prompt')
|
|
99
|
+
) {
|
|
100
|
+
process.stderr.write('Aborted by user.\n');
|
|
101
|
+
} else {
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
98
104
|
} finally {
|
|
99
105
|
unlisten();
|
|
100
106
|
}
|
|
@@ -76,13 +76,14 @@ function main(runtimeArgs, config) {
|
|
|
76
76
|
|
|
77
77
|
async function pickCommit(commitsStr) {
|
|
78
78
|
// Ensure colors are always used (even when running with `returnOutput: <number>`).
|
|
79
|
-
const {default:
|
|
79
|
+
const {default: select, Separator} = await importWithEnv(() => import('@inquirer/select'), {FORCE_COLOR: '1'});
|
|
80
80
|
|
|
81
81
|
const commits = commitsStr.
|
|
82
82
|
split('\n').
|
|
83
83
|
map(line => line.trim()).
|
|
84
84
|
filter(Boolean).
|
|
85
|
-
|
|
85
|
+
map(line => ({name: line, value: line.replace(/\s+.*$/, '')})).
|
|
86
|
+
concat(new Separator());
|
|
86
87
|
|
|
87
88
|
const unlisten = processUtils.doOnExit(process, code => {
|
|
88
89
|
if (code === 0) {
|
|
@@ -94,17 +95,23 @@ async function pickCommit(commitsStr) {
|
|
|
94
95
|
});
|
|
95
96
|
|
|
96
97
|
try {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
const commit = await select({
|
|
99
|
+
message: 'Pick a commit:',
|
|
100
|
+
choices: commits,
|
|
101
|
+
default: commits[0].value,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return commit;
|
|
105
|
+
} catch (err) {
|
|
106
|
+
if (
|
|
107
|
+
(err instanceof Error) &&
|
|
108
|
+
(err.name === 'ExitPromptError') &&
|
|
109
|
+
err.message.startsWith('User force closed the prompt')
|
|
110
|
+
) {
|
|
111
|
+
process.stderr.write('Aborted by user.\n');
|
|
112
|
+
} else {
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
108
115
|
} finally {
|
|
109
116
|
unlisten();
|
|
110
117
|
}
|
package/lib/constants.js
CHANGED
|
@@ -238,13 +238,15 @@ const PRINT_NVM_UPDATE_INSTRUCTIONS_CODE = (currentVersionCmd, repoSlug, fullIns
|
|
|
238
238
|
|
|
239
239
|
// NOTE 1: Node.js commands that are directly evaluated in a *nix shell should not contain backticks (`` ` ``).
|
|
240
240
|
// NOTE 2: Node.js commands that are directly evaluated in a *nix shell should have any dollar-signs (`$`) excaped.
|
|
241
|
-
// NOTE 3: Due to how
|
|
241
|
+
// NOTE 3: Due to how this code is used, escaped characters need to be double-escaped (`\\\\`).
|
|
242
242
|
// NOTE 4: The above notes should be also taken into account for the passed in strings used directly in the command.
|
|
243
243
|
const UPDATE_DEPS_CODE = (updateCmd, depsProp) =>
|
|
244
244
|
`node --eval "/* Update ${depsProp}. */ ` +
|
|
245
245
|
`const deps = Object.keys(require('./package.json').${depsProp} || {}).map(x => x + '@latest'); ` +
|
|
246
|
+
`const cmd = '${updateCmd} ' + deps.join(' '); ` +
|
|
246
247
|
`console.log('\\\\nUpdating ' + deps.length + ' ${depsProp}...'); ` +
|
|
247
|
-
|
|
248
|
+
'console.log(\' Command: \' + cmd); ' +
|
|
249
|
+
'deps.length && child_process.execSync(cmd, {shell: true, stdio: \'inherit\'});' +
|
|
248
250
|
'"';
|
|
249
251
|
let nupCode, nudCode, yupCode, yudCode;
|
|
250
252
|
|
package/lib/utils.js
CHANGED
|
@@ -13,6 +13,7 @@ const internal = {
|
|
|
13
13
|
_fsExistsSync,
|
|
14
14
|
_fsRealpathSync,
|
|
15
15
|
_getPlatform,
|
|
16
|
+
_importWithEnv,
|
|
16
17
|
_onError,
|
|
17
18
|
_wrapLine,
|
|
18
19
|
};
|
|
@@ -47,6 +48,24 @@ function _getPlatform() {
|
|
|
47
48
|
return PLATFORM;
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
async function _importWithEnv(importFn, tempEnvVars) {
|
|
52
|
+
const {env} = process;
|
|
53
|
+
|
|
54
|
+
const tempEnvVarNames = Object.keys(tempEnvVars);
|
|
55
|
+
const originalValues = tempEnvVarNames.
|
|
56
|
+
filter(name => hasOwnProperty(env, name)).
|
|
57
|
+
reduce((aggr, name) => Object.assign(aggr, {[name]: env[name]}), {});
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
Object.assign(env, tempEnvVars);
|
|
61
|
+
return await importFn();
|
|
62
|
+
} finally {
|
|
63
|
+
tempEnvVarNames.forEach(name => hasOwnProperty(originalValues, name) ?
|
|
64
|
+
env[name] = originalValues[name] :
|
|
65
|
+
delete env[name]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
50
69
|
async function _onError(err) {
|
|
51
70
|
// NOTE:
|
|
52
71
|
// Avoid eagerly loading `chalk` at the top of the file to allow for it to be imported (directly
|
|
@@ -90,22 +109,8 @@ function hasOwnProperty(obj, prop) {
|
|
|
90
109
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
91
110
|
}
|
|
92
111
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const tempEnvVarNames = Object.keys(tempEnvVars);
|
|
97
|
-
const originalValues = tempEnvVarNames.
|
|
98
|
-
filter(name => hasOwnProperty(env, name)).
|
|
99
|
-
reduce((aggr, name) => Object.assign(aggr, {[name]: env[name]}), {});
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
Object.assign(env, tempEnvVars);
|
|
103
|
-
return await importFn();
|
|
104
|
-
} finally {
|
|
105
|
-
tempEnvVarNames.forEach(name => hasOwnProperty(originalValues, name) ?
|
|
106
|
-
env[name] = originalValues[name] :
|
|
107
|
-
delete env[name]);
|
|
108
|
-
}
|
|
112
|
+
function importWithEnv(importFn, tempEnvVars) {
|
|
113
|
+
return internal._importWithEnv(importFn, tempEnvVars);
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
function isMain(fileUrl) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gkalpak/aliases",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "My global aliases.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Utility"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"start": "run-s dev",
|
|
10
10
|
"build": "node scripts/build",
|
|
11
|
-
"dev": "watch
|
|
11
|
+
"dev": "node --watch-path=lib/ --watch-path=test/ scripts/run-npm-script ~~dev",
|
|
12
12
|
"postinstall": "npm run ~~platformize-bin",
|
|
13
13
|
"prelint": "npm run prepare-bin-local",
|
|
14
14
|
"lint": "npm run ~~lint",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"pretest-unit": "npm run prepare-bin-local",
|
|
25
25
|
"test-unit": "npm run ~~test-unit",
|
|
26
26
|
"postversion": "git push && git push --tags",
|
|
27
|
+
"~~dev": "run-s ~~lint ~~test-unit",
|
|
27
28
|
"~~lint": "eslint ./",
|
|
28
29
|
"~~platformize-bin": "node scripts/platformize-bin",
|
|
29
30
|
"~~test-e2e": "jasmine test/e2e/**/*.spec.js",
|
|
@@ -198,29 +199,18 @@
|
|
|
198
199
|
}
|
|
199
200
|
},
|
|
200
201
|
"dependencies": {
|
|
201
|
-
"@gkalpak/cli-utils": "^0.
|
|
202
|
+
"@gkalpak/cli-utils": "^0.3.1",
|
|
203
|
+
"@inquirer/select": "^5.1.0",
|
|
202
204
|
"chalk": "^5.6.2",
|
|
203
|
-
"
|
|
204
|
-
"is-wsl": "^3.1.0"
|
|
205
|
+
"is-wsl": "^3.1.1"
|
|
205
206
|
},
|
|
206
207
|
"devDependencies": {
|
|
207
208
|
"eslint": "^8.57.1",
|
|
208
209
|
"eslint-plugin-import": "^2.32.0",
|
|
209
210
|
"eslint-plugin-jasmine": "^4.2.2",
|
|
210
|
-
"jasmine": "^
|
|
211
|
+
"jasmine": "^6.1.0",
|
|
211
212
|
"npm-run-all": "^4.1.5",
|
|
212
213
|
"shelljs": "^0.10.0",
|
|
213
|
-
"strip-ansi": "^7.
|
|
214
|
-
"watch": "^1.0.2"
|
|
215
|
-
},
|
|
216
|
-
"overrides-comments": {
|
|
217
|
-
"watch": {
|
|
218
|
-
"exec-sh": "Fix vulnerability in transitive dependency `merge` (see https://github.com/gkalpak/aliases/security/dependabot/1)."
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
"overrides": {
|
|
222
|
-
"watch": {
|
|
223
|
-
"exec-sh": "0.4.0"
|
|
224
|
-
}
|
|
214
|
+
"strip-ansi": "^7.2.0"
|
|
225
215
|
}
|
|
226
216
|
}
|
|
@@ -20,7 +20,7 @@ function _main() {
|
|
|
20
20
|
const defaultScripts = findFiles(BIN_DIR).filter(x => defaultExtRe.test(x));
|
|
21
21
|
defaultScripts.forEach(defaultScriptPath => {
|
|
22
22
|
const activeScriptPath = defaultScriptPath.replace(defaultExtRe, '.js');
|
|
23
|
-
|
|
23
|
+
renameSync(defaultScriptPath, activeScriptPath);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
// "Activate" any platform-specific scripts.
|
|
@@ -33,26 +33,27 @@ function _main() {
|
|
|
33
33
|
const activeScriptMode = statSync(activeScriptPath).mode;
|
|
34
34
|
|
|
35
35
|
// Back up the default script for future restoration.
|
|
36
|
-
|
|
36
|
+
renameSync(activeScriptPath, defaultScriptPath);
|
|
37
37
|
|
|
38
38
|
// Copy the platform-specific script (not move just in case).
|
|
39
|
-
|
|
39
|
+
copyFileSync(platformScriptPath, activeScriptPath);
|
|
40
40
|
|
|
41
41
|
// Preserve active script mode (including "executability") for the scripts to work on *nix platforms.
|
|
42
42
|
chmodSync(activeScriptPath, activeScriptMode);
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
46
|
+
/**
|
|
47
|
+
* @param {string} rootDir
|
|
48
|
+
* @returns {string[]}
|
|
49
|
+
*/
|
|
50
50
|
function findFiles(rootDir) {
|
|
51
51
|
const unvisitedDirectories = [rootDir];
|
|
52
|
+
/** @type {string[]} */
|
|
52
53
|
const files = [];
|
|
53
54
|
|
|
54
55
|
while (unvisitedDirectories.length) {
|
|
55
|
-
const currentDir = unvisitedDirectories.pop();
|
|
56
|
+
const currentDir = /** @type {string} */(unvisitedDirectories.pop());
|
|
56
57
|
readdirSync(currentDir).forEach(name => {
|
|
57
58
|
const path = join(currentDir, name);
|
|
58
59
|
const info = statSync(path);
|
|
@@ -64,7 +65,3 @@ function findFiles(rootDir) {
|
|
|
64
65
|
|
|
65
66
|
return files;
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
-
function moveFile(fromPath, toPath) {
|
|
69
|
-
renameSync(fromPath, toPath);
|
|
70
|
-
}
|