@vltpkg/cli-sdk 1.4.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/allow-skills.d.ts +36 -0
- package/dist/allow-skills.js +49 -0
- package/dist/commands/build.d.ts +15 -4
- package/dist/commands/build.js +50 -12
- package/dist/commands/ci.d.ts +2 -2
- package/dist/commands/ci.js +10 -2
- 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/init.js +4 -3
- package/dist/commands/install/reporter.d.ts +1 -1
- package/dist/commands/install/reporter.js +91 -5
- package/dist/commands/install.d.ts +50 -4
- package/dist/commands/install.js +107 -25
- package/dist/commands/list.js +8 -2
- package/dist/commands/publish.d.ts +0 -1
- package/dist/commands/publish.js +27 -16
- package/dist/commands/query.js +8 -2
- package/dist/commands/setup.d.ts +28 -2
- package/dist/commands/setup.js +185 -3
- package/dist/commands/skills.d.ts +56 -0
- package/dist/commands/skills.js +267 -0
- package/dist/commands/token.js +1 -1
- package/dist/commands/uninstall.d.ts +15 -4
- package/dist/commands/uninstall.js +32 -4
- package/dist/commands/unpublish.d.ts +0 -1
- package/dist/commands/unpublish.js +17 -4
- package/dist/commands/update.d.ts +13 -1
- package/dist/commands/update.js +18 -1
- package/dist/config/definition.d.ts +52 -0
- package/dist/config/definition.js +109 -1
- package/dist/config/index.d.ts +26 -3
- package/dist/config/index.js +149 -7
- package/dist/custom-help.js +4 -0
- 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 +14 -3
- package/dist/install-receipt.d.ts +40 -0
- package/dist/install-receipt.js +69 -0
- package/dist/load-command.d.ts +2 -0
- package/dist/migrate-workspaces.d.ts +16 -0
- package/dist/migrate-workspaces.js +44 -0
- package/dist/output.js +13 -0
- package/dist/parse-add-remove-args.js +2 -14
- package/dist/print-err.js +4 -1
- package/dist/publish-config.d.ts +9 -0
- package/dist/publish-config.js +8 -0
- 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/dist/skills-prompt.d.ts +28 -0
- package/dist/skills-prompt.js +78 -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
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Streams to prompt on; default stdin and stdout. */
|
|
2
|
+
export type PromptStreams = {
|
|
3
|
+
input?: NodeJS.ReadableStream;
|
|
4
|
+
output?: NodeJS.WritableStream;
|
|
5
|
+
};
|
|
6
|
+
/** Prompts can be answered: stdin is a TTY. */
|
|
7
|
+
export declare const interactive: () => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* `[y/N]` question: true on `y`/`yes` (any case), else false. Closed
|
|
10
|
+
* input (EOF, ctrl+C/D): undefined (cancel).
|
|
11
|
+
*/
|
|
12
|
+
export declare const confirm: (question: string, s?: PromptStreams) => Promise<boolean | undefined>;
|
|
13
|
+
export type EditQueryOptions = PromptStreams & {
|
|
14
|
+
/** stored query, shown above the prompt; unset: nothing stored */
|
|
15
|
+
current?: string;
|
|
16
|
+
/** editable answer */
|
|
17
|
+
prefill: string;
|
|
18
|
+
/**
|
|
19
|
+
* throws on an invalid query: its message is printed and the
|
|
20
|
+
* question asked again
|
|
21
|
+
*/
|
|
22
|
+
check: (q: string) => Promise<unknown>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Ask for a new `allow-skills`, prefilled. Empty answer or closed
|
|
26
|
+
* input: undefined (cancel).
|
|
27
|
+
*/
|
|
28
|
+
export declare const editQuery: ({ current, prefill, check, ...s }: EditQueryOptions) => Promise<string | undefined>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline/promises';
|
|
2
|
+
import { asError } from '@vltpkg/types';
|
|
3
|
+
import { styleTextStdout } from "./output.js";
|
|
4
|
+
/** Prompts can be answered: stdin is a TTY. */
|
|
5
|
+
export const interactive = () => process.stdin.isTTY;
|
|
6
|
+
const open = (s) => {
|
|
7
|
+
const rl = createInterface({
|
|
8
|
+
input: s.input ?? process.stdin,
|
|
9
|
+
output: s.output ?? process.stdout,
|
|
10
|
+
// prefill and line editing
|
|
11
|
+
terminal: true,
|
|
12
|
+
});
|
|
13
|
+
// ctrl+C cancels
|
|
14
|
+
rl.on('SIGINT', () => rl.close());
|
|
15
|
+
let done = false;
|
|
16
|
+
const closed = new Promise(r => rl.once('close', () => {
|
|
17
|
+
done = true;
|
|
18
|
+
r(undefined);
|
|
19
|
+
}));
|
|
20
|
+
// the answer; undefined once the input is closed (EOF, ctrl+C/D)
|
|
21
|
+
const ask = async (query, prefill) => {
|
|
22
|
+
if (done)
|
|
23
|
+
return undefined;
|
|
24
|
+
const q = rl.question(query).catch(() => undefined);
|
|
25
|
+
if (prefill)
|
|
26
|
+
rl.write(prefill);
|
|
27
|
+
return Promise.race([q, closed]);
|
|
28
|
+
};
|
|
29
|
+
return { rl, ask };
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* `[y/N]` question: true on `y`/`yes` (any case), else false. Closed
|
|
33
|
+
* input (EOF, ctrl+C/D): undefined (cancel).
|
|
34
|
+
*/
|
|
35
|
+
export const confirm = async (question, s = {}) => {
|
|
36
|
+
const { rl, ask } = open(s);
|
|
37
|
+
try {
|
|
38
|
+
const a = await ask(question);
|
|
39
|
+
return a === undefined ? undefined : /^y(es)?$/i.test(a.trim());
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
rl.close();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Ask for a new `allow-skills`, prefilled. Empty answer or closed
|
|
47
|
+
* input: undefined (cancel).
|
|
48
|
+
*/
|
|
49
|
+
export const editQuery = async ({ current, prefill, check, ...s }) => {
|
|
50
|
+
const output = s.output ?? process.stdout;
|
|
51
|
+
if (current !== undefined) {
|
|
52
|
+
output.write('\n⚠️ The new allow-skills replaces the current one. Make sure it still\n' +
|
|
53
|
+
'selects every skill you want: skills it no longer selects are unlinked.\n\n' +
|
|
54
|
+
styleTextStdout('yellow', `Current allow-skills: ${current}`) +
|
|
55
|
+
'\n');
|
|
56
|
+
}
|
|
57
|
+
const prompt = styleTextStdout('cyan', 'New allow-skills: ');
|
|
58
|
+
const { rl, ask } = open(s);
|
|
59
|
+
try {
|
|
60
|
+
let fill = prefill;
|
|
61
|
+
for (;;) {
|
|
62
|
+
const a = (await ask(prompt, fill))?.trim();
|
|
63
|
+
if (!a)
|
|
64
|
+
return undefined;
|
|
65
|
+
try {
|
|
66
|
+
await check(a);
|
|
67
|
+
return a;
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
output.write(`${asError(e).message}\n`);
|
|
71
|
+
fill = a;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
rl.close();
|
|
77
|
+
}
|
|
78
|
+
};
|
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",
|