Skip to content

Commit

Permalink
Merge pull request #88 from XionWCFM/analytics
Browse files Browse the repository at this point in the history
refactor: Biome 설정 추가, 패키지 분리
  • Loading branch information
XionWCFM authored Dec 7, 2024
2 parents bbeb038 + 51e590c commit 6e2fd4f
Show file tree
Hide file tree
Showing 267 changed files with 4,691 additions and 29,708 deletions.
78 changes: 78 additions & 0 deletions .cli/package.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import path from "node:path";
import chalk from "chalk";
import { Command } from "commander";
import { mkdirSync, writeFileSync } from "fs-extra";
import inquirer from "inquirer";

const program = new Command();

program.name("repo-cli").description("모노레포 프로젝트를 위한 패키지 생성기").version("1.0.0");

async function createPackage() {
const answers = await inquirer.prompt([
{
type: "input",
name: "projectName",
message: "Enter a package name",
validate: (input: string) => !!input || "Enter a package name",
},
{
type: "list",
name: "tsconfig",
message: "Choose a tsconfig",
choices: ["base.json", "react-library.json", "nextjs.json"],
},
]);

const projectName = answers.projectName;
const tsconfig = answers.tsconfig;

const packagePath = path.resolve(process.cwd(), `packages/${projectName}`);
const srcPath = path.join(packagePath, "src");
const indexPath = path.join(srcPath, "index.ts");
const packageJsonPath = path.join(packagePath, "package.json");
const tsconfigPath = path.join(packagePath, "tsconfig.json");

try {
// 패키지 디렉토리 생성
mkdirSync(packagePath, { recursive: true });

// src 디렉토리와 index.ts 생성
mkdirSync(srcPath, { recursive: true });
writeFileSync(indexPath, ""); // 빈 파일 생성

// package.json 생성
const packageJson = {
name: `@repo/${projectName}`,
version: "0.0.0",
main: "index.js",
devDependencies: {
"@repo/typescript-config": "workspace:*",
typescript: "latest",
},
};
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));

// tsconfig.json 생성
const tsconfigContent = {
extends: `@repo/typescript-config/${tsconfig}`,
compilerOptions: {
outDir: "dist",
rootDir: "src",
},
include: ["src"],
exclude: ["node_modules", "dist"],
};
writeFileSync(tsconfigPath, JSON.stringify(tsconfigContent, null, 2));
} catch (err) {
if (err instanceof Error) {
console.error(chalk.red(`❌ 패키지 생성 중 에러가 발생했습니다: ${err.message}`));
} else {
console.error(chalk.red(`❌ 패키지 생성 중 알 수 없는 에러가 발생했습니다.`));
}
}
}

program.action(createPackage);

program.parse(process.argv);
9 changes: 6 additions & 3 deletions .github/workflows/pr-size-labeler.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: labeler
name: Pr Size Labeler

on: [pull_request]

Expand Down Expand Up @@ -27,5 +27,8 @@ jobs:
This PR exceeds the recommended size of 1000 lines.
Please make sure you are NOT addressing multiple issues with one PR.
Note this PR might be rejected due to its size.
github_api_url: 'https://api.github.com'
files_to_ignore: 'pnpm-lock.yaml'
github_api_url: "https://api.github.com"
files_to_ignore: |
pnpm-lock.yaml
package-lock.json
yarn.lock
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ node_modules
.env.test.local
.env.production.local

storybook-static

# Testing
coverage

Expand Down Expand Up @@ -40,3 +42,5 @@ yarn-error.log*
# Misc
.DS_Store
*.pem

*storybook.log
2 changes: 1 addition & 1 deletion .ncurc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"upgrade": true,
"target": "minor",
"target": "latest",
"reject": ["tailwind-merge", "react", "react-dom", "@types/react", "@types/react-dom", "@biomejs/biome", "next"],
"deep": true
}
10 changes: 7 additions & 3 deletions apps/blog/app/(blog)/posts/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Metadata } from "next";
import { redirect } from "next/navigation";
import { getAllPosts, getPost } from "~/entities/post/model/post.service";
import PostDetailPage from "~/page/post-detail.page";
import PostDetailPage from "~/page/PostDetailPage";
import { BASE_SITE_URL } from "~/shared/constants";
import { createMetadata } from "~/shared/utils/external/create-meta-data";

Expand All @@ -14,7 +14,9 @@ type PostProps = {
export const generateMetadata = async ({ params }: PostProps): Promise<Metadata> => {
const slug = (await params).slug;
const post = await getPost(slug);
if (!post) throw new Error("Post not found");
if (!post) {
throw new Error("Post not found");
}
const url = `${BASE_SITE_URL}/posts/${post.filePath.join("/")}`;
const metaData = createMetadata({ description: post.description, title: post.title, url });
return metaData;
Expand All @@ -32,6 +34,8 @@ export const dynamic = "force-static";
export default async function Post({ params }: PostProps) {
const slug = (await params).slug;
const post = await getPost(slug);
if (!post) return redirect("/");
if (!post) {
return redirect("/");
}
return <PostDetailPage post={post} />;
}
15 changes: 0 additions & 15 deletions apps/blog/app/(portfolio)/layout.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions apps/blog/app/(portfolio)/portfolio/page.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions apps/blog/app/(resume)/layout.tsx

This file was deleted.

75 changes: 0 additions & 75 deletions apps/blog/app/(resume)/resume/page.tsx

This file was deleted.

29 changes: 9 additions & 20 deletions apps/blog/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@ import "@xionwcfm/token/style";
import "@xionwcfm/xds/style";
import "./globals.css";

import { GoogleAnalytics, GoogleTagManager } from "@next/third-parties/google";

import { AnalyticsProvider } from "@repo/analytics";
import { env } from "@repo/env";
import { Pretendard } from "@repo/font";
import { Toaster } from "@xionwcfm/xds/toast";
import type { Metadata } from "next";
import { Noto_Sans_KR } from "next/font/google";
import { ClarityScript } from "~/app/script/clarity.script";
import { ENVIRONMENT } from "~/shared/environment";
import { AUTHOR_NAME, BASE_SITE_DESCRIPTION, BASE_SITE_TITLE, BASE_SITE_URL } from "../src/shared/constants";
import { createMetadata } from "../src/shared/utils/external/create-meta-data";
import AutoRefresh from "./auto-refresh";

const notoSansKr = Noto_Sans_KR({
weight: ["200", "300", "500", "700"],
subsets: ["latin"],
display: "swap",
});

export const metadata: Metadata = {
...createMetadata({
authors: AUTHOR_NAME,
Expand All @@ -27,7 +19,7 @@ export const metadata: Metadata = {
url: BASE_SITE_URL,
}),
verification: {
google: ENVIRONMENT.GSC_ID,
google: env.NEXT_PUBLIC_GSC_ID,
},
};

Expand All @@ -37,16 +29,13 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang="ko" className={notoSansKr.className}>
<body>
<AutoRefresh>
{children}
<html lang="ko">
<body className={Pretendard.className}>
<AnalyticsProvider>
<AutoRefresh>{children}</AutoRefresh>
<Toaster visibleToasts={1} />
</AutoRefresh>
</AnalyticsProvider>
</body>
<ClarityScript />
<GoogleTagManager gtmId={"GTM-52Z3Z37J"} />
<GoogleAnalytics gaId={"G-59H4F1GZ8B"} />
</html>
);
}
12 changes: 7 additions & 5 deletions apps/blog/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import { Paragraph, Stack } from "@xionwcfm/xds";
import { getAllPostsSortedByReleaseDate } from "~/entities/post/model/post.service";
import { PostCard } from "~/entities/post/ui/post/post-card";
import { PostCard } from "~/entities/post/ui/post/PostCard";
import { AUTHOR_NICKNAME } from "~/shared/constants";
import { MainXionWCFM } from "~/shared/ui/common/main-xion-wcfm";
import { Separate } from "~/shared/ui/common/separate";
import { MainXionWcfm } from "~/shared/ui/common/MainXionWcfm";
import { Separate } from "~/shared/ui/common/Separate";
import { Footer } from "~/widgets/footer";
import { StaticHeader } from "~/widgets/header/static-header";

export default async function RootPage() {
const posts = await getAllPostsSortedByReleaseDate();
const currentPostTitle = `${AUTHOR_NICKNAME}의 최신 포스트 보기`;

return (
<>
<Stack className=" min-h-screen bg-neutral-50">
<StaticHeader />
<Stack w={"100%"} justify={"center"} items={"center"}>
<Stack w={"screen"} maxW={{ md: "768", xl: "1024" }}>
<MainXionWCFM />
<MainXionWcfm />
<Stack px={{ initial: "16", md: "0" }}>
<Stack>
<Paragraph color={"neutral-800"} weight={"light"} size={"7"} responsive mt={"24"} mb={"12"}>
<Paragraph color={"neutral-800"} weight={"light"} size={"7"} responsive={true} mt={"24"} mb={"12"}>
{currentPostTitle}
</Paragraph>
<Separate />
Expand Down
4 changes: 2 additions & 2 deletions apps/blog/app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
lastModified: new Date(),
}));

const MAIN_URL = {
const mainUrl = {
url: BASE_SITE_URL,
lastModified: new Date(),
};

const allSitesMap = postUrls.concat(MAIN_URL);
const allSitesMap = postUrls.concat(mainUrl);
return allSitesMap;
}
Loading

0 comments on commit 6e2fd4f

Please sign in to comment.