Skip to content

Commit

Permalink
feat: add pdp projects to try prisma
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur-arch committed May 17, 2024
1 parent 77ef5bc commit cda088d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ export default class Cli {

// Collect user input
if (!this.args.folder.length) {
this.args.folder = await prompts.getRootDir();
const projects = await prompts.selectOrmOrPDP()
if( projects !== "orm" ) {
this.args.folder = projects;
} else {
this.args.folder = await prompts.getRootDir();
}
this.projects = this.projects.filter((project) =>
project.startsWith(this.args.folder),
);
Expand Down
29 changes: 29 additions & 0 deletions src/cli/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,34 @@ const getTemplate = async (projects: string[]): Promise<string> => {
return template;
};

const selectOrmOrPDP = async (): Promise<string> => {
logger.success(
`\nThese options correspond to the root directories in the prisma-examples repository:\n`,
);
const { start } = await inquirer.prompt({
// @ts-expect-error Inquirer doesn't register the type.
type: "search-list",
message: `Which examples do you want to explore?`,
name: "start",
choices: [
{
name: "ORM",
value: "orm",
},
{
name: "Prisma Accelerate",
value: "accelerate",
},
{
name: "Prisma Pulse",
value: "pulse",
},
],
});

return start;
};

const getRootDir = async (): Promise<string> => {
logger.success(
`\nThese options correspond to the root directories in the prisma-examples repository:\n`,
Expand Down Expand Up @@ -114,6 +142,7 @@ const getProjectDirectory = async (): Promise<string> => {
};

export default {
selectOrmOrPDP,
getInstallSelection,
getProjectDirectory,
getProjectName,
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export const EXAMPLES_REPO_INTERCEPTOR = // "http://localhost:3000/api/intercept
"https://www.try-prisma-analytics.com/api/interceptor";
// "https://www.try-prisma-analytics.vercel.app/api/interceptor";

export const EXAMPLES_DIR_ACCEPT = ["javascript", "typescript"];
export const EXAMPLES_DIR_ACCEPT = ["javascript", "typescript", "accelerate", "pulse"];
2 changes: 1 addition & 1 deletion src/helpers/getProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default async function getProjects() {
return { ...prev, [curr.path]: [] };
}
}, {});

for (const key in mergedData) {
if (!mergedData[key].includes("package.json")) {
delete mergedData[key];
Expand Down

0 comments on commit cda088d

Please sign in to comment.