diff --git a/extensions/terminal-suggest/scripts/update-specs.js b/extensions/terminal-suggest/scripts/update-specs.js index 63084a09445..775c5dd3264 100644 --- a/extensions/terminal-suggest/scripts/update-specs.js +++ b/extensions/terminal-suggest/scripts/update-specs.js @@ -24,73 +24,14 @@ const specSpecificReplaceStrings = new Map([ [ 'import { ai } from "@fig/autocomplete-generators";', 'function ai(...args: any[]): undefined { return undefined; }' - ], [ - 'const remoteURLs = out.split("\\n").reduce((dict, line) => {', - 'const remoteURLs = out.split("\\n").reduce>((dict, line) => {', ], [ 'prompt: async ({ executeCommand }) => {', 'prompt: async ({ executeCommand }: any) => {' ], [ 'message: async ({ executeCommand }) =>', 'message: async ({ executeCommand }: any) =>' - ], [ - 'if (parts.length > 1) {', - 'if (parts && parts.length > 1) {' - ], [ - 'if (seen.has(suggestion.name)) return false;', - 'if (!suggestion) return false;\n\t\t\t\tif (seen.has(suggestion.name)) return false;' - ], [ - 'return pp(', - 'return pp?.(' ] ]], - ['kill', [[ - 'out.match(/\\w+/g)', - 'out.match(/\\w+/g)?' - ]]], - ['node', [[ - 'const isAdonisJsonPresentCommand = "test -f .adonisrc.json";', - '' - ]]], - ['npm', [ - [ - 'keywords?.length > 0 ? `+keywords:${keywords.join(",")}` : "";', - 'keywords && keywords.length > 0 ? `+keywords:${keywords.join(",")}` : "";' - ], [ - 'return results.map((item) => ({', - 'return results.map((item: any) => ({' - ], [ - 'const suggestions = [];', - 'const suggestions: Fig.Suggestion[] = [];' - ] - ]], - ['nvm', [[ - 'const pattern: Fig.Arg = {\n\tname: "pattern",\n};', - '' - ]]], - ['pnpm', [ - [ - 'if (parts.length > 1) {', - 'if (parts && parts.length > 1) {' - ], [ - 'const packages = postProcess(', - 'if (postProcess === undefined) return undefined;\n\t\tconst packages = postProcess(' - ], [ - ').map(({ name }) => name as string);', - ')?.filter((e) => e !== null).map(({ name }) => name as string);' - ], [ - '.filter((name) => nodeClis.has(name))', - '?.filter((name) => nodeClis.has(name))' - ] - ]], - ['ssh', [[ - 'const includeLines = await Promise.all(', - 'const includeLines: any = await Promise.all(' - ]]], - ['yarn', [[ - '(item) =>', - '(item: any) =>' - ]]], ]); for (const spec of upstreamSpecs) { diff --git a/extensions/terminal-suggest/src/completions/upstream/git.ts b/extensions/terminal-suggest/src/completions/upstream/git.ts index 03668c69e2d..56468610acc 100644 --- a/extensions/terminal-suggest/src/completions/upstream/git.ts +++ b/extensions/terminal-suggest/src/completions/upstream/git.ts @@ -296,14 +296,16 @@ export const gitGenerators: Record = { remotes: { script: ["git", "--no-optional-locks", "remote", "-v"], postProcess: function (out) { - const remoteURLs = out.split("\n").reduce>((dict, line) => { - const pair = line.split("\t"); - const remote = pair[0]; - const url = pair[1].split(" ")[0]; + const remoteURLs = out + .split("\n") + .reduce>((dict, line) => { + const pair = line.split("\t"); + const remote = pair[0]; + const url = pair[1].split(" ")[0]; - dict[remote] = url; - return dict; - }, {}); + dict[remote] = url; + return dict; + }, {}); return Object.keys(remoteURLs).map((remote) => { const url = remoteURLs[remote]; diff --git a/extensions/terminal-suggest/src/completions/upstream/node.ts b/extensions/terminal-suggest/src/completions/upstream/node.ts index 38a1c44b140..d6e7b52e17d 100644 --- a/extensions/terminal-suggest/src/completions/upstream/node.ts +++ b/extensions/terminal-suggest/src/completions/upstream/node.ts @@ -83,7 +83,6 @@ const completionSpec: Fig.Subcommand = { }, ], generateSpec: async (tokens, executeShellCommand) => { - if ( ( await executeShellCommand({ diff --git a/extensions/terminal-suggest/src/completions/upstream/npm.ts b/extensions/terminal-suggest/src/completions/upstream/npm.ts index 809f15752c6..aa142e05661 100644 --- a/extensions/terminal-suggest/src/completions/upstream/npm.ts +++ b/extensions/terminal-suggest/src/completions/upstream/npm.ts @@ -81,10 +81,12 @@ export const createNpmSearchHandler = } const results = keywordParameter ? data.results : data; - return results.map((item: any) => ({ - name: item.package.name, - description: item.package.description, - })) as Fig.Suggestion[]; + return results.map( + (item: { package: { name: string; description: string } }) => ({ + name: item.package.name, + description: item.package.description, + }) + ) as Fig.Suggestion[]; } catch (error) { console.error({ error }); return []; diff --git a/extensions/terminal-suggest/src/completions/upstream/nvm.ts b/extensions/terminal-suggest/src/completions/upstream/nvm.ts index 81724580835..6adafbcb174 100644 --- a/extensions/terminal-suggest/src/completions/upstream/nvm.ts +++ b/extensions/terminal-suggest/src/completions/upstream/nvm.ts @@ -28,8 +28,6 @@ const args: Fig.Arg = { isVariadic: true, }; - - const name: Fig.Arg = { name: "name", }; diff --git a/extensions/terminal-suggest/src/completions/upstream/pnpm.ts b/extensions/terminal-suggest/src/completions/upstream/pnpm.ts index deaa454f750..9ce7c798208 100644 --- a/extensions/terminal-suggest/src/completions/upstream/pnpm.ts +++ b/extensions/terminal-suggest/src/completions/upstream/pnpm.ts @@ -991,7 +991,10 @@ const completionSpec: Fig.Spec = { script: string[]; }; - if (postProcess === undefined) return undefined; + if (postProcess === undefined) { + return undefined; + } + const packages = postProcess( ( await executeShellCommand({ @@ -1000,7 +1003,9 @@ const completionSpec: Fig.Spec = { }) ).stdout, tokens - )?.filter((e) => e !== null).map(({ name }) => name as string); + ) + ?.filter((e) => e !== null) + .map(({ name }) => name as string); const subcommands = packages ?.filter((name) => nodeClis.has(name)) diff --git a/extensions/terminal-suggest/src/completions/upstream/ssh.ts b/extensions/terminal-suggest/src/completions/upstream/ssh.ts index 2fa0884c63d..4998530d3ec 100644 --- a/extensions/terminal-suggest/src/completions/upstream/ssh.ts +++ b/extensions/terminal-suggest/src/completions/upstream/ssh.ts @@ -43,7 +43,7 @@ const getConfigLines = async ( .map((line) => line.split(" ")[1]); // Get the lines of every include file - const includeLines: any = await Promise.all( + const includeLines: string[][] = await Promise.all( includes.map((file) => getConfigLines(file, executeShellCommand, home, basePath) ) diff --git a/extensions/terminal-suggest/src/completions/upstream/yarn.ts b/extensions/terminal-suggest/src/completions/upstream/yarn.ts index e8d5a2011ce..04c573a151b 100644 --- a/extensions/terminal-suggest/src/completions/upstream/yarn.ts +++ b/extensions/terminal-suggest/src/completions/upstream/yarn.ts @@ -367,7 +367,7 @@ export const createCLIsGenerator: Fig.Generator = { postProcess: function (out) { try { return JSON.parse(out).results.map( - (item: any) => + (item: { package: { name: string; description: string } }) => ({ name: item.package.name.substring(7), description: item.package.description,