@vltpkg/cli-sdk 1.5.0 → 1.6.0
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/dist/commands/build.d.ts +8 -3
- package/dist/commands/build.js +31 -3
- package/dist/commands/ci.d.ts +1 -1
- package/dist/commands/create.d.ts +2 -1
- package/dist/commands/create.js +2 -3
- package/dist/commands/exec.d.ts +2 -1
- package/dist/commands/exec.js +2 -3
- package/dist/commands/install/reporter.d.ts +1 -1
- package/dist/commands/install/reporter.js +45 -5
- package/dist/commands/install.d.ts +21 -3
- package/dist/commands/install.js +84 -30
- package/dist/commands/list.js +5 -1
- package/dist/commands/query.js +5 -1
- package/dist/commands/setup.d.ts +28 -2
- package/dist/commands/setup.js +185 -3
- package/dist/commands/skills.js +2 -3
- package/dist/commands/token.js +1 -1
- package/dist/commands/uninstall.d.ts +10 -3
- package/dist/commands/uninstall.js +28 -2
- package/dist/commands/update.d.ts +1 -1
- package/dist/config/definition.d.ts +32 -0
- package/dist/config/definition.js +60 -0
- package/dist/config/index.d.ts +26 -3
- package/dist/config/index.js +149 -7
- package/dist/global-bin-dir.d.ts +37 -0
- package/dist/global-bin-dir.js +138 -0
- package/dist/global-project.d.ts +18 -0
- package/dist/global-project.js +67 -0
- package/dist/global-state.d.ts +24 -0
- package/dist/global-state.js +94 -0
- package/dist/global.d.ts +78 -0
- package/dist/global.js +409 -0
- package/dist/index.js +7 -2
- package/dist/install-receipt.d.ts +40 -0
- package/dist/install-receipt.js +69 -0
- package/dist/output.js +13 -0
- package/dist/parse-add-remove-args.js +2 -14
- package/dist/query-auth.d.ts +3 -2
- package/dist/query-auth.js +6 -4
- package/dist/reload-config.js +2 -1
- package/dist/require-registry.d.ts +7 -0
- package/dist/require-registry.js +13 -1
- package/dist/self-update.d.ts +74 -0
- package/dist/self-update.js +401 -0
- package/dist/shell-setup/env.d.ts +9 -0
- package/dist/shell-setup/env.js +25 -0
- package/dist/shell-setup/index.d.ts +69 -0
- package/dist/shell-setup/index.js +213 -0
- package/dist/shell-setup/posix.d.ts +36 -0
- package/dist/shell-setup/posix.js +158 -0
- package/dist/shell-setup/windows.d.ts +39 -0
- package/dist/shell-setup/windows.js +151 -0
- package/dist/shell.d.ts +18 -0
- package/dist/shell.js +110 -0
- package/package.json +30 -28
package/dist/shell.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
const shells = new Map([
|
|
4
|
+
['bash', 'bash'],
|
|
5
|
+
['zsh', 'zsh'],
|
|
6
|
+
['fish', 'fish'],
|
|
7
|
+
['nu', 'nu'],
|
|
8
|
+
['pwsh', 'pwsh'],
|
|
9
|
+
['powershell', 'pwsh'],
|
|
10
|
+
['sh', 'sh'],
|
|
11
|
+
['dash', 'sh'],
|
|
12
|
+
['ksh', 'sh'],
|
|
13
|
+
['mksh', 'sh'],
|
|
14
|
+
['ash', 'sh'],
|
|
15
|
+
]);
|
|
16
|
+
const isSep = (c, win32) => c === '/' || (win32 && c === '\\');
|
|
17
|
+
// rest of `path` after `home`: '' for home itself, undefined outside
|
|
18
|
+
const homeRest = (path, home, win32) => !home ? undefined
|
|
19
|
+
: path === home ? ''
|
|
20
|
+
: path.startsWith(home) && isSep(path[home.length], win32) ?
|
|
21
|
+
path.slice(home.length)
|
|
22
|
+
: undefined;
|
|
23
|
+
/** `~/x` for a path under the home dir */
|
|
24
|
+
export const prettyPath = (path, home = homedir(), win32 = process.platform === 'win32') => {
|
|
25
|
+
const rest = homeRest(path, home, win32);
|
|
26
|
+
return rest === undefined ? path : `~${rest}`;
|
|
27
|
+
};
|
|
28
|
+
/** the user's shell, from `SHELL`, or a guess on win32 */
|
|
29
|
+
export const detectShell = (env = process.env, platform = process.platform) => {
|
|
30
|
+
const { SHELL } = env;
|
|
31
|
+
if (SHELL) {
|
|
32
|
+
const name = SHELL.replace(/^.*[\\/]/, '')
|
|
33
|
+
.replace(/\.exe$/i, '')
|
|
34
|
+
.toLowerCase();
|
|
35
|
+
return shells.get(name) ?? 'unknown';
|
|
36
|
+
}
|
|
37
|
+
if (platform !== 'win32')
|
|
38
|
+
return 'unknown';
|
|
39
|
+
// set machine-wide, PowerShell adds the user module dir
|
|
40
|
+
const mods = (env.PSModulePath ?? '').split(';').filter(Boolean);
|
|
41
|
+
return mods.length >= 3 ? 'pwsh' : 'cmd';
|
|
42
|
+
};
|
|
43
|
+
const opts = ({ env = process.env, platform = process.platform, home = homedir(), }) => ({
|
|
44
|
+
env,
|
|
45
|
+
platform,
|
|
46
|
+
home,
|
|
47
|
+
win32: platform === 'win32',
|
|
48
|
+
});
|
|
49
|
+
const escape = (s, chars, esc = '\\') => s.replace(chars, c => esc + c);
|
|
50
|
+
// `$HOME/x`, or the path, `/c/x` style on win32
|
|
51
|
+
const posixInner = (dir, o, chars) => {
|
|
52
|
+
const { home, win32 } = opts(o);
|
|
53
|
+
const slash = (p) => (win32 ? p.replace(/\\/g, '/') : p);
|
|
54
|
+
const rest = homeRest(dir, home, win32);
|
|
55
|
+
if (rest !== undefined)
|
|
56
|
+
return '$HOME' + escape(slash(rest), chars);
|
|
57
|
+
const p = win32 ?
|
|
58
|
+
slash(dir).replace(/^([a-z]):/i, (_, d) => `/${d.toLowerCase()}`)
|
|
59
|
+
: dir;
|
|
60
|
+
return escape(p, chars);
|
|
61
|
+
};
|
|
62
|
+
const shChars = /[\\"$`]/g;
|
|
63
|
+
/** `dir` double-quoted for a POSIX shell, `$HOME` late-bound */
|
|
64
|
+
export const posixPath = (dir, o = {}) => `"${posixInner(dir, o, shChars)}"`;
|
|
65
|
+
/** `dir` double-quoted for fish, `$HOME` late-bound */
|
|
66
|
+
export const fishPath = (dir, o = {}) => `"${posixInner(dir, o, /[\\"$]/g)}"`;
|
|
67
|
+
/** the line that adds `dir` to the `PATH` in `shell` */
|
|
68
|
+
export const shellPathCommand = (shell, dir, o = {}) => {
|
|
69
|
+
const { home, win32 } = opts(o);
|
|
70
|
+
const rest = homeRest(dir, home, win32);
|
|
71
|
+
switch (shell) {
|
|
72
|
+
case 'fish':
|
|
73
|
+
return `fish_add_path ${fishPath(dir, o)}`;
|
|
74
|
+
case 'nu':
|
|
75
|
+
return `$env.PATH = ($env.PATH | prepend "${escape(dir, /[\\"]/g)}")`;
|
|
76
|
+
case 'pwsh': {
|
|
77
|
+
const p = rest === undefined ?
|
|
78
|
+
escape(dir, /[`"$]/g, '`')
|
|
79
|
+
: '$HOME' + escape(rest, /[`"$]/g, '`');
|
|
80
|
+
return `$env:PATH += "${win32 ? ';' : ':'}${p}"`;
|
|
81
|
+
}
|
|
82
|
+
case 'cmd':
|
|
83
|
+
return `set "PATH=%PATH%;${rest === undefined ? dir : '%USERPROFILE%' + rest}"`;
|
|
84
|
+
default:
|
|
85
|
+
return `export PATH="${posixInner(dir, o, shChars)}:$PATH"`;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/** rc file to add the `PATH` line to, for display */
|
|
89
|
+
export const shellRcFile = (shell, o = {}) => {
|
|
90
|
+
const { env, platform, home, win32 } = opts(o);
|
|
91
|
+
switch (shell) {
|
|
92
|
+
case 'zsh':
|
|
93
|
+
return prettyPath(`${env.ZDOTDIR || home}/.zshrc`, home, win32);
|
|
94
|
+
case 'bash': {
|
|
95
|
+
const has = (f) => existsSync(`${home}/${f}`);
|
|
96
|
+
// like `vlt setup --path`: never a new .bashrc
|
|
97
|
+
if (platform !== 'darwin' && has('.bashrc'))
|
|
98
|
+
return '~/.bashrc';
|
|
99
|
+
// a new .bash_profile would shadow .profile
|
|
100
|
+
const f = ['.bash_profile', '.bash_login'].find(has);
|
|
101
|
+
return `~/${f ?? '.profile'}`;
|
|
102
|
+
}
|
|
103
|
+
case 'sh':
|
|
104
|
+
return env.ENV ? prettyPath(env.ENV, home, win32) : '~/.profile';
|
|
105
|
+
case 'pwsh':
|
|
106
|
+
return '$PROFILE';
|
|
107
|
+
default:
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/cli-sdk",
|
|
3
3
|
"description": "The source for the vlt CLI",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -14,33 +14,35 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@resvg/resvg-wasm": "^2.6.2",
|
|
17
|
-
"@vltpkg/
|
|
18
|
-
"@vltpkg/
|
|
19
|
-
"@vltpkg/
|
|
20
|
-
"@vltpkg/
|
|
21
|
-
"@vltpkg/
|
|
22
|
-
"@vltpkg/
|
|
23
|
-
"@vltpkg/graph
|
|
24
|
-
"@vltpkg/
|
|
25
|
-
"@vltpkg/
|
|
26
|
-
"@vltpkg/
|
|
27
|
-
"@vltpkg/package-
|
|
28
|
-
"@vltpkg/
|
|
29
|
-
"@vltpkg/
|
|
30
|
-
"@vltpkg/
|
|
31
|
-
"@vltpkg/
|
|
32
|
-
"@vltpkg/
|
|
33
|
-
"@vltpkg/
|
|
34
|
-
"@vltpkg/
|
|
35
|
-
"@vltpkg/
|
|
36
|
-
"@vltpkg/
|
|
37
|
-
"@vltpkg/
|
|
38
|
-
"@vltpkg/
|
|
39
|
-
"@vltpkg/
|
|
40
|
-
"@vltpkg/
|
|
41
|
-
"@vltpkg/
|
|
42
|
-
"@vltpkg/
|
|
43
|
-
"@vltpkg/
|
|
17
|
+
"@vltpkg/cmd-shim": "1.6.0",
|
|
18
|
+
"@vltpkg/config": "1.6.0",
|
|
19
|
+
"@vltpkg/dep-id": "1.6.0",
|
|
20
|
+
"@vltpkg/dot-prop": "1.6.0",
|
|
21
|
+
"@vltpkg/error-cause": "1.6.0",
|
|
22
|
+
"@vltpkg/git": "1.6.0",
|
|
23
|
+
"@vltpkg/graph": "1.6.0",
|
|
24
|
+
"@vltpkg/graph-run": "1.6.0",
|
|
25
|
+
"@vltpkg/init": "1.6.0",
|
|
26
|
+
"@vltpkg/output": "1.6.0",
|
|
27
|
+
"@vltpkg/package-info": "1.6.0",
|
|
28
|
+
"@vltpkg/package-json": "1.6.0",
|
|
29
|
+
"@vltpkg/pick-manifest": "1.6.0",
|
|
30
|
+
"@vltpkg/promise-spawn": "1.6.0",
|
|
31
|
+
"@vltpkg/query": "1.6.0",
|
|
32
|
+
"@vltpkg/registry-client": "1.6.0",
|
|
33
|
+
"@vltpkg/rollback-remove": "1.6.0",
|
|
34
|
+
"@vltpkg/run": "1.6.0",
|
|
35
|
+
"@vltpkg/security-archive": "1.6.0",
|
|
36
|
+
"@vltpkg/semver": "1.6.0",
|
|
37
|
+
"@vltpkg/spec": "1.6.0",
|
|
38
|
+
"@vltpkg/tar": "1.6.0",
|
|
39
|
+
"@vltpkg/types": "1.6.0",
|
|
40
|
+
"@vltpkg/url-open": "1.6.0",
|
|
41
|
+
"@vltpkg/vlt-json": "1.6.0",
|
|
42
|
+
"@vltpkg/vlx": "1.6.0",
|
|
43
|
+
"@vltpkg/which": "1.6.0",
|
|
44
|
+
"@vltpkg/workspaces": "1.6.0",
|
|
45
|
+
"@vltpkg/xdg": "1.6.0",
|
|
44
46
|
"ansi-to-pre": "^1.0.6",
|
|
45
47
|
"beautiful-mermaid": "^1.1.3",
|
|
46
48
|
"chalk": "^5.6.2",
|