Skip to content

Commit

Permalink
Add BulletList to installable components (#209)
Browse files Browse the repository at this point in the history
* add BulletList to installable components

* Change install dir from src/@mailingui to src/mailingui

* Use same file-structure as we have in our project

* remove duplicated dir

* make basePath mandatory arg of createFile
  • Loading branch information
ericvalcik authored Aug 14, 2023
1 parent b1ec402 commit 42b3def
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 1 addition & 2 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import execa from "execa";
import ora from "ora";
import prompts from "prompts";
import {
BASE_URL,
DEPENDENCIES as REQUIRED_DEPENDENCIES,
SETTINGS_FILE_NAME,
} from "../constants";
Expand All @@ -19,7 +18,7 @@ export const init = new Command()
.option(
"-p, --path <path>",
"define base path to your MailingUI components",
"./src/@mailingui"
"./src/mailingui"
)
.option("-o, --overwrite", "overwrite existing configuration", false)
.action(async (options) => {
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/utils/createFile.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import path from "path";
import { Component } from "../types";
import fs from "fs";
import prompts from "prompts";
import chalk from "chalk";
import { Component } from "../types";

export async function createFile(
componentName: string,
components: Record<string, Component>,
basePath?: string,
basePath: string,
overwrite?: boolean
) {
const component = components[componentName];
Expand All @@ -16,9 +16,9 @@ export async function createFile(
await createFile(dependency, components, basePath, overwrite);
}

const directoryPath = basePath
? `${basePath}/components/${componentName}`
: path.dirname(component.path);
const directoryPath = `${basePath}/components/${path.basename(
path.dirname(component.path)
)}`;

if (!fs.existsSync(directoryPath)) {
fs.mkdirSync(directoryPath, { recursive: true });
Expand Down
8 changes: 6 additions & 2 deletions src/app/api/components/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from "fs";
import { NextResponse } from "next/server";

const getFileProps = (path: string) => ({
path,
Expand All @@ -12,6 +13,7 @@ type SupportedComponents =
| "emoji"
| "heroSection"
| "list"
| "bulletList"
| "socialIcon"
| "text";

Expand Down Expand Up @@ -49,6 +51,10 @@ const getComponents = (): Record<
dependencies: [],
...getFileProps("./src/mailingui/components/list/List.tsx"),
},
bulletList: {
dependencies: [],
...getFileProps("./src/mailingui/components/list/BulletList.tsx"),
},
socialIcon: {
dependencies: [],
...getFileProps("./src/mailingui/components/social-icon/SocialIcon.tsx"),
Expand All @@ -67,5 +73,3 @@ export const GET = async () => {
return NextResponse.error();
}
};

import { NextResponse } from "next/server";

1 comment on commit 42b3def

@vercel
Copy link

@vercel vercel bot commented on 42b3def Aug 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.