Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
}
},
"dependencies": {
"@inquirer/select": "^1.3.1",
"@oclif/core": "3.16.0",
"@oclif/plugin-autocomplete": "3.0.4",
"@oclif/plugin-commands": "3.1.0",
Expand Down Expand Up @@ -162,7 +163,7 @@
"@salesforce/plugin-templates": "56.0.8",
"@salesforce/plugin-trust": "3.2.5",
"@salesforce/plugin-user": "3.2.0",
"@salesforce/sf-plugins-core": "5.0.13",
"@salesforce/sf-plugins-core": "7.0.0",
"debug": "^4.3.4"
},
"pinnedDependencies": [
Expand Down
30 changes: 17 additions & 13 deletions src/hooks/incomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,41 @@

import * as os from 'node:os';
import { Command, Hook, toConfiguredId, toStandardizedId, Interfaces, loadHelpClass } from '@oclif/core';
import { Prompter } from '@salesforce/sf-plugins-core';

function buildChoices(
matches: Command.Loadable[],
config: Interfaces.Config
): Array<{ name: string; value: Command.Loadable }> {
): Array<{ name: string; value: Command.Loadable['id'] }> {
const configuredIds = matches.map((p) => toConfiguredId(p.id, config));
const maxCommandLength = configuredIds.reduce((max, id) => Math.max(max, id.length), 0);
return matches.map((p, i) => {
const summary = p.summary ?? p.description?.split(os.EOL)[0] ?? '';
return {
name: `${configuredIds[i].padEnd(maxCommandLength + 5, ' ')}${summary}`,
value: p,
value: p.id,
short: configuredIds[i],
};
});
}

async function determineCommand(config: Interfaces.Config, matches: Command.Loadable[]): Promise<string> {
const prompter = new Prompter();
const choices = buildChoices(matches, config);
const { command } = await prompter.timedPrompt<{ command: Command.Loadable }>([
{
name: 'command',
type: 'list',
message: 'Which of these commands do you mean',
choices,
},
const [{ setTimeout }, { SfError }, select] = await Promise.all([
import('node:timers/promises'),
import('@salesforce/core'),
import('@inquirer/select'),
]);

return command.id;
const choices = buildChoices(matches, config);
const answer = select.default({
message: 'Which of these commands do you mean',
choices,
});

const timeout = setTimeout(60_000, undefined, { ref: false }).then(() => {
answer.cancel();
throw new SfError('Prompt timed out.');
});
return Promise.race([answer, timeout]);
}

const hook: Hook.CommandIncomplete = async function ({ config, matches, argv }) {
Expand Down
132 changes: 103 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,15 @@
resolved "https://registry.yarnpkg.com/@hutson/parse-repository-url/-/parse-repository-url-3.0.2.tgz#98c23c950a3d9b6c8f0daed06da6c3af06981340"
integrity sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q==

"@inquirer/confirm@^2.0.15":
version "2.0.15"
resolved "https://registry.yarnpkg.com/@inquirer/confirm/-/confirm-2.0.15.tgz#b5512ed190efd8c5b96e0969115756b48546ab36"
integrity sha512-hj8Q/z7sQXsF0DSpLQZVDhWYGN6KLM/gNjjqGkpKwBzljbQofGjn0ueHADy4HUY+OqDHmXuwk/bY+tZyIuuB0w==
dependencies:
"@inquirer/core" "^5.1.1"
"@inquirer/type" "^1.1.5"
chalk "^4.1.2"

"@inquirer/core@^3.1.1":
version "3.1.2"
resolved "https://registry.yarnpkg.com/@inquirer/core/-/core-3.1.2.tgz#d9691e6ffae85935685641550b8370ab7e599caa"
Expand All @@ -548,7 +557,57 @@
strip-ansi "^6.0.1"
wrap-ansi "^6.2.0"

"@inquirer/type@^1.1.2":
"@inquirer/core@^5.1.1":
version "5.1.1"
resolved "https://registry.yarnpkg.com/@inquirer/core/-/core-5.1.1.tgz#849d4846aea68371c133df6ec9059f5e5bd30d30"
integrity sha512-IuJyZQUg75+L5AmopgnzxYrgcU6PJKL0hoIs332G1Gv55CnmZrhG6BzNOeZ5sOsTi1YCGOopw4rYICv74ejMFg==
dependencies:
"@inquirer/type" "^1.1.5"
"@types/mute-stream" "^0.0.4"
"@types/node" "^20.9.0"
"@types/wrap-ansi" "^3.0.0"
ansi-escapes "^4.3.2"
chalk "^4.1.2"
cli-spinners "^2.9.1"
cli-width "^4.1.0"
figures "^3.2.0"
mute-stream "^1.0.0"
run-async "^3.0.0"
signal-exit "^4.1.0"
strip-ansi "^6.0.1"
wrap-ansi "^6.2.0"

"@inquirer/input@^1.2.14":
version "1.2.14"
resolved "https://registry.yarnpkg.com/@inquirer/input/-/input-1.2.14.tgz#8951867618bb5cd16dd096e02404eec225a92207"
integrity sha512-tISLGpUKXixIQue7jypNEShrdzJoLvEvZOJ4QRsw5XTfrIYfoWFqAjMQLerGs9CzR86yAI89JR6snHmKwnNddw==
dependencies:
"@inquirer/core" "^5.1.1"
"@inquirer/type" "^1.1.5"
chalk "^4.1.2"

"@inquirer/password@^1.1.14":
version "1.1.14"
resolved "https://registry.yarnpkg.com/@inquirer/password/-/password-1.1.14.tgz#c1fc139efe84a38986870a1bcf80718050f82bbf"
integrity sha512-vL2BFxfMo8EvuGuZYlryiyAB3XsgtbxOcFs4H9WI9szAS/VZCAwdVqs8rqEeaAf/GV/eZOghIOYxvD91IsRWSg==
dependencies:
"@inquirer/input" "^1.2.14"
"@inquirer/type" "^1.1.5"
ansi-escapes "^4.3.2"
chalk "^4.1.2"

"@inquirer/select@^1.3.1":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@inquirer/select/-/select-1.3.1.tgz#b10bb8d4ba72f08eb887b3d948eb734d680897c6"
integrity sha512-EgOPHv7XOHEqiBwBJTyiMg9r57ySyW4oyYCumGp+pGyOaXQaLb2kTnccWI6NFd9HSi5kDJhF7YjA+3RfMQJ2JQ==
dependencies:
"@inquirer/core" "^5.1.1"
"@inquirer/type" "^1.1.5"
ansi-escapes "^4.3.2"
chalk "^4.1.2"
figures "^3.2.0"

"@inquirer/type@^1.1.2", "@inquirer/type@^1.1.5":
version "1.1.5"
resolved "https://registry.yarnpkg.com/@inquirer/type/-/type-1.1.5.tgz#b8c171f755859c8159b10e41e1e3a88f0ca99d7f"
integrity sha512-wmwHvHozpPo4IZkkNtbYenem/0wnfI6hvOcGKmPEa0DwuaH5XUQzFqy6OpEpjEegZMhYIk8HDYITI16BPLtrRA==
Expand Down Expand Up @@ -1096,7 +1155,7 @@
read-package-json-fast "^3.0.0"
which "^4.0.0"

"@oclif/core@3.16.0", "@oclif/core@^3", "@oclif/core@^3.0.4", "@oclif/core@^3.10.1", "@oclif/core@^3.10.2", "@oclif/core@^3.10.8", "@oclif/core@^3.11.0", "@oclif/core@^3.12.0", "@oclif/core@^3.13.1", "@oclif/core@^3.14.1", "@oclif/core@^3.15.0", "@oclif/core@^3.15.1":
"@oclif/core@3.16.0", "@oclif/core@^3", "@oclif/core@^3.0.4", "@oclif/core@^3.10.1", "@oclif/core@^3.10.2", "@oclif/core@^3.10.8", "@oclif/core@^3.11.0", "@oclif/core@^3.12.0", "@oclif/core@^3.13.1", "@oclif/core@^3.14.1", "@oclif/core@^3.15.0", "@oclif/core@^3.15.1", "@oclif/core@^3.16.0":
version "3.16.0"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.16.0.tgz#682657cb5e4a3262a47e26e0c8a7bf0343acaf76"
integrity sha512-/PIz+udzb59XE8O/bQvqlCtXy6RByEHH0KsrAJNa/ZrqtdsLmeDNJcHdgygFHx+nz+PYMoUzsyzJMau++EDNoQ==
Expand Down Expand Up @@ -1978,18 +2037,18 @@
resolved "https://registry.yarnpkg.com/@salesforce/schemas/-/schemas-1.6.1.tgz#7d1c071e1e509ca9d2d8a6e48ac7447dd67a534d"
integrity sha512-eVy947ZMxCJReKJdgfddUIsBIbPTa/i8RwQGwxq4/ss38H5sLOAeSTaun9V7HpJ1hkpDznWKfgzYvjsst9K6ig==

"@salesforce/sf-plugins-core@5.0.13", "@salesforce/sf-plugins-core@^5.0.10", "@salesforce/sf-plugins-core@^5.0.11", "@salesforce/sf-plugins-core@^5.0.13", "@salesforce/sf-plugins-core@^5.0.3", "@salesforce/sf-plugins-core@^5.0.9":
version "5.0.13"
resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-5.0.13.tgz#f2941527d66ded5750a6646e146af047ab72acc9"
integrity sha512-b5R8krKeOIkW0hPxvfpm8T5tCSyWW7MDERnJwm/FXq4ueUJsC1/TCWSscyVKPSZ0VRcEFbzOWKJvpV/omB1D9w==
"@salesforce/sf-plugins-core@7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-7.0.0.tgz#56cb4eaafcd04a183938d86c5e93323e037b15ab"
integrity sha512-vl53Ee0/eg9wgvtWro6kX82/943s28Hph/o3lTQk6URorfqMC+zH0RGKJj1X0VKeLhDSOCRYXqIu54jE8AZ/3g==
dependencies:
"@oclif/core" "^3.15.1"
"@salesforce/core" "^6.4.1"
"@inquirer/confirm" "^2.0.15"
"@inquirer/password" "^1.1.14"
"@oclif/core" "^3.16.0"
"@salesforce/core" "^6.4.2"
"@salesforce/kit" "^3.0.15"
"@salesforce/ts-types" "^2.0.9"
"@types/inquirer" "^8.2.3"
chalk "^4"
inquirer "^8.2.5"
chalk "^5.3.0"

"@salesforce/sf-plugins-core@^4", "@salesforce/sf-plugins-core@^4.0.0":
version "4.1.3"
Expand All @@ -2004,6 +2063,19 @@
chalk "^4"
inquirer "^8.2.5"

"@salesforce/sf-plugins-core@^5.0.10", "@salesforce/sf-plugins-core@^5.0.11", "@salesforce/sf-plugins-core@^5.0.13", "@salesforce/sf-plugins-core@^5.0.3", "@salesforce/sf-plugins-core@^5.0.9":
version "5.0.13"
resolved "https://registry.yarnpkg.com/@salesforce/sf-plugins-core/-/sf-plugins-core-5.0.13.tgz#f2941527d66ded5750a6646e146af047ab72acc9"
integrity sha512-b5R8krKeOIkW0hPxvfpm8T5tCSyWW7MDERnJwm/FXq4ueUJsC1/TCWSscyVKPSZ0VRcEFbzOWKJvpV/omB1D9w==
dependencies:
"@oclif/core" "^3.15.1"
"@salesforce/core" "^6.4.1"
"@salesforce/kit" "^3.0.15"
"@salesforce/ts-types" "^2.0.9"
"@types/inquirer" "^8.2.3"
chalk "^4"
inquirer "^8.2.5"

"@salesforce/source-deploy-retrieve@10.2.6", "@salesforce/source-deploy-retrieve@^10.2.1", "@salesforce/source-deploy-retrieve@^10.2.5":
version "10.2.6"
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-10.2.6.tgz#37189ff3c2185158a856137e63a811bdd5b05b43"
Expand Down Expand Up @@ -2394,12 +2466,19 @@
dependencies:
"@types/node" "*"

"@types/node@*", "@types/node@^20.4.8":
version "20.8.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.5.tgz#13352ae1f80032171616910e8aba2e3e52e57d96"
integrity sha512-SPlobFgbidfIeOYlzXiEjSYeIJiOCthv+9tSQVpvk4PAdIIc+2SmjNVzWXk9t0Y7dl73Zdf+OgXKHX9XtkqUpw==
"@types/mute-stream@^0.0.4":
version "0.0.4"
resolved "https://registry.yarnpkg.com/@types/mute-stream/-/mute-stream-0.0.4.tgz#77208e56a08767af6c5e1237be8888e2f255c478"
integrity sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==
dependencies:
"@types/node" "*"

"@types/node@*", "@types/node@^20.4.8", "@types/node@^20.9.0":
version "20.10.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.6.tgz#a3ec84c22965802bf763da55b2394424f22bfbb5"
integrity sha512-Vac8H+NlRNNlAmDfGUP7b5h/KA+AtWIzuXy0E6OyP8f1tCLYAtPvKRRDJjAPqhpCb0t6U2j7/xqAuLEebW2kiw==
dependencies:
undici-types "~5.25.1"
undici-types "~5.26.4"

"@types/node@^12.19.9":
version "12.20.55"
Expand Down Expand Up @@ -3543,10 +3622,10 @@ cli-progress@^3.12.0:
dependencies:
string-width "^4.2.3"

cli-spinners@^2.5.0, cli-spinners@^2.9.0:
version "2.9.1"
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.1.tgz#9c0b9dad69a6d47cbb4333c14319b060ed395a35"
integrity sha512-jHgecW0pxkonBJdrKsqxgRX9AcG+u/5k0Q7WPDfi8AogLAdwxEkyYYNWwZ5GvVFoFx2uiY1eNcSK00fh+1+FyQ==
cli-spinners@^2.5.0, cli-spinners@^2.9.0, cli-spinners@^2.9.1:
version "2.9.2"
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.9.2.tgz#1773a8f4b9c4d6ac31563df53b3fc1d79462fe41"
integrity sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==

cli-table3@^0.6.0, cli-table3@^0.6.3:
version "0.6.3"
Expand Down Expand Up @@ -9748,10 +9827,10 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7:
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==

signal-exit@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.0.2.tgz#ff55bb1d9ff2114c13b400688fa544ac63c36967"
integrity sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==
signal-exit@^4.0.1, signal-exit@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04"
integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==

sigstore@^1.3.0, sigstore@^1.4.0, sigstore@^1.7.0:
version "1.9.0"
Expand Down Expand Up @@ -10566,11 +10645,6 @@ unbox-primitive@^1.0.2:
has-symbols "^1.0.3"
which-boxed-primitive "^1.0.2"

undici-types@~5.25.1:
version "5.25.3"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.25.3.tgz#e044115914c85f0bcbb229f346ab739f064998c3"
integrity sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
Expand Down