Skip to content

Commit

Permalink
Allow for an autocomplete search with project selection (#24315)
Browse files Browse the repository at this point in the history
Useful if you have >5 projects - you can just start typing to narrow the
list.

GitOrigin-RevId: 2b31700ee0ce33744b91cea5b55713dda22c8979
  • Loading branch information
nipunn1313 authored and Convex, Inc. committed Apr 5, 2024
1 parent 05812d2 commit 48e4597
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
"find-up": "^6.3.0",
"http-proxy": "~1.18.1",
"inquirer": "^9.1.4",
"inquirer-search-list": "~1.2.6",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jwt-encode": "~1.0.1",
Expand Down
1 change: 1 addition & 0 deletions scripts/test-esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ for (const dir of fs.readdirSync(path.join(__dirname, "../dist/esm"))) {

// ts-node-esm requires respects Node.js import urls (requires .js extensions)
child_process.execFileSync("node_modules/.bin/ts-node-esm", [
"--files",
"src/cli/index.ts",
"--version",
]);
4 changes: 4 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { networkTest } from "./network_test.js";
import { convexExport } from "./convexExport.js";
import { env } from "./env.js";
import { data } from "./data.js";
import inquirer from "inquirer";
import inquirerSearchList from "inquirer-search-list";

const MINIMUM_MAJOR_VERSION = 16;
const MINIMUM_MINOR_VERSION = 15;
Expand All @@ -51,6 +53,8 @@ async function main() {
});
}

inquirer.registerPrompt("search-list", inquirerSearchList);

const nodeVersion = process.versions.node;
const majorVersion = parseInt(nodeVersion.split(".")[0], 10);
const minorVersion = parseInt(nodeVersion.split(".")[1], 10);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export async function validateOrSelectProject(
{
name: "project",
message: multiProjectPrompt,
type: "list",
type: "search-list",
choices: nonDemoProjects.map((project: Project) => ({
name: `${project.name} (${project.slug})`,
value: project.slug,
Expand Down
4 changes: 4 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "inquirer-search-list" {
const mod: import("inquirer").prompts.PromptConstructor;
export = mod;
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"include": ["src", ".eslintrc.cjs"],
/* src/cli uses a different tsconfig.json and .test.ts files should not be compiled */
"compileOnSave": true,
"compilerOptions": {
/* Basic Options */
Expand Down

0 comments on commit 48e4597

Please sign in to comment.