autocomplete
autocomplete copied to clipboard
Merge npx binary running across tools
trafficstars
TODO:
- [ ] Extract create-PACKAGE loginc from yarn
- [ ] Make sure redwood and similar aliases work
- [ ] Maybe port to deno? (since it technically supports it?)
- [ ] Convert
npxSuggestionsarray in npx.ts to load more specs (instead of hardcoding name and icon)
Overview
src/pnpx.ts:
Info:
src/bunx.ts:
Info:
src/npx.ts:
Info:
Single Functions:
postProcess:
function (out) {
const globalCLIs = npxSuggestions.map((suggestion) => suggestion.name);
return out
.split("\n")
.filter((name) => (filterOutGlobal ? !globalCLIs.includes(name) : true))
.map((name) => ({
name,
icon: "fig://icon?type=command",
loadSpec: binToSpecOverrides[name] || name,
}));
}
URLs:
https://raw.githubusercontent.com/babel/logo/master/babel.pnghttps://reactnative.dev/img/pwa/manifest-icon-512.pnghttps://vitejs.dev/logo.svghttps://reactnative.dev/img/pwa/manifest-icon-512.pnghttps://tailwindcss.com/favicons/favicon-32x32.pnghttps://nextjs.org/static/favicon/favicon-16x16.pnghttps://raw.githubusercontent.com/nuxt/framework/main/docs/public/icon.pnghttps://raw.githubusercontent.com/pmndrs/branding/master/logo.svghttps://raw.githubusercontent.com/prisma/docs/main/src/images/favicon-16x16.pnghttps://raw.githubusercontent.com/eslint/eslint.org/main/src/static/icon-512.pnghttps://prettier.io/icon.pnghttps://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Typescript_logo_2020.svg/240px-Typescript_logo_2020.svg.pnghttps://avatars.githubusercontent.com/u/20165699?s=200&v=4https://fig.io/icons/fig-light.pnghttps://fig.io/icons/fig-light.pnghttps://fig.io/icons/fig-light.pnghttps://fig.io/icons/fig-light.pnghttps://nextjs.org/static/favicon/favicon-16x16.pnghttps://create.t3.gg/favicon.svghttps://discordjs.dev/favicon-32x32.pnghttps://raw.githubusercontent.com/remotion-dev/remotion/main/packages/docs/static/img/logo-small.pnghttps://raw.githubusercontent.com/remotion-dev/remotion/main/packages/docs/static/img/logo-small.pnghttps://remix.run/favicon-light.1.pnghttps://remix.run/favicon-light.1.pnghttps://playwright.dev/img/playwright-logo.svghttps://raw.githubusercontent.com/preset/preset/main/.github/assets/logo.svghttps://raw.githubusercontent.com/mikro-orm/mikro-orm/master/docs/static/img/favicon.icohttps://capacitorjs.com/docs/img/meta/favicon.pnghttps://capacitorjs.com/docs/img/meta/favicon.pnghttps://avatars.githubusercontent.com/u/25686615?s=200&v=4https://stenciljs.com/assets/icon/favicon.icohttps://static1.smartbear.co/swagger/media/assets/swagger_fav.pnghttps://static1.smartbear.co/swagger/media/assets/swagger_fav.pnghttps://s1.wp.com/i/webclip.pnghttps://astro.build/favicon.svg
src/_utils/spec.ts:
Info:
src/pnpm.ts:
Info:
Single Functions:
postProcess:
function (out) {
const output = filterMessages(out);
if (output.startsWith("fatal:")) {
return [];
}
return output.split("\n").map((elm) => {
let name = elm.trim();
const parts = elm.match(/\S+/g);
if (parts.length > 1) {
if (parts[0] == "*") {
// Current branch.
return {
name: elm.replace("*", "").trim(),
description: "Current branch",
icon: "⭐️",
};
} else if (parts[0] == "+") {
// Branch checked out in another worktree.
name = elm.replace("+", "").trim();
}
}
return {
name,
description: "Branch",
icon: "fig://icon?type=git",
};
});
}
postProcess:
function (out) {
/**
* out
* @example
* ```
* Legend: production dependency, optional only, dev only
*
* /xxxx/xxxx/<package-name> (PRIVATE)
*
* dependencies:
* lodash 4.17.21
* foo link:packages/foo
*
* devDependencies:
* typescript 4.7.4
* ```
*/
if (out.includes("ERR_PNPM")) {
return [];
}
const output = out
.split("\n")
.slice(3)
// remove empty lines, "*dependencies:" lines, local workspace packages (eg: "foo":"workspace:*")
.filter(
(item) =>
!!item &&
!item.toLowerCase().includes("dependencies") &&
!item.includes("link:")
)
.map((item) => item.replace(/\s/, "@")); // typescript 4.7.4 -> [email protected]
return output.map((pkg) => {
return {
name: pkg,
icon: "fig://icon?type=package",
};
});
}
src/yarn.ts:
Info:
Single Functions:
postProcess:
function (out) {
if (out.trim() == "") {
return [];
}
try {
const startIndex = out.indexOf("{");
const endIndex = out.indexOf("}");
let output = out.substring(startIndex, endIndex + 1);
// TODO: fix hacky code
// reason: JSON parse was not working without double quotes
output = output
.replace(/\'/gi, '"')
.replace("lastUpdateCheck", '"lastUpdateCheck"')
.replace("registry", '"lastUpdateCheck"');
const configObject = JSON.parse(output);
if (configObject) {
return Object.keys(configObject).map((key) => ({ name: key }));
}
} catch (e) {}
return [];
}
postProcess:
function (out, context = []) {
if (out.trim() === "") {
return [];
}
try {
const packageContent = JSON.parse(out);
const dependencies = packageContent["dependencies"] ?? {};
const devDependencies = packageContent["devDependencies"];
const optionalDependencies = packageContent["optionalDependencies"] ?? {};
Object.assign(dependencies, devDependencies, optionalDependencies);
return Object.keys(dependencies)
.filter((pkgName) => {
const isListed = context.some((current) => current === pkgName);
return !isListed;
})
.map((pkgName) => ({
name: pkgName,
icon: "📦",
description: dependencies[pkgName]
? "dependency"
: optionalDependencies[pkgName]
? "optionalDependency"
: "devDependency",
}));
} catch (e) {
console.error(e);
return [];
}
}
script:
function (context) {
if (context[context.length - 1] === "") return undefined;
const searchTerm = "create-" + context[context.length - 1];
return [
"curl",
"-s",
"-H",
"Accept: application/json",
`https://api.npms.io/v2/search?q=${searchTerm}&size=20`,
];
}
postProcess:
function (out) {
try {
return JSON.parse(out).results.map(
(item) =>
({
name: item.package.name.substring(7),
description: item.package.description,
}) as Fig.Suggestion
) as Fig.Suggestion[];
} catch (e) {
return [];
}
}
postProcess:
function (out: string) {
if (out.trim() == "") {
return [];
}
try {
const packageContent = JSON.parse(out);
const scripts = packageContent["scripts"];
if (scripts) {
return Object.keys(scripts).map((script) => ({
name: script,
}));
}
} catch (e) {}
return [];
}
URLs:
https://api.npms.io/v2/search?q=
Hello @Zeko369, thank you very much for creating a Pull Request! Here is a small checklist to get this PR merged as quickly as possible:
- [ ] Do all subcommands / options which take arguments include the
argsproperty (args: {})? - [ ] Are all options modular? E.g.
-a-u-xinstead of-aux - [ ] Have all other checks passed?
Please add a 👍 as a reaction to this comment to show that you read this.