feat(create-turbo): apply official-starter transform

This commit is contained in:
Turbobot
2025-02-08 13:42:54 -08:00
committed by ryan
parent 1eb868b58c
commit 661f8656f4
89 changed files with 5823 additions and 763 deletions
-9
View File
@@ -1,9 +0,0 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@repo/eslint-config/react-internal.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};
+4
View File
@@ -0,0 +1,4 @@
import { config } from "@repo/eslint-config/react-internal";
/** @type {import("eslint").Linter.Config} */
export default config;
+15 -7
View File
@@ -1,21 +1,29 @@
{
"name": "@repo/ui",
"version": "0.0.0",
"private": true,
"exports": {
"./button": "./src/button.tsx"
"./button": "./src/button.tsx",
"./card": "./src/card.tsx",
"./code": "./src/code.tsx"
},
"scripts": {
"lint": "eslint \"**/*.ts*\" --max-warnings 0"
"lint": "eslint . --max-warnings 0",
"generate:component": "turbo gen react-component",
"check-types": "tsc --noEmit"
},
"devDependencies": {
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"eslint": "^8.57.0",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"typescript": "5.5.4"
"@turbo/gen": "^2.4.0",
"@types/node": "^22.13.0",
"@types/react": "19.0.8",
"@types/react-dom": "19.0.3",
"eslint": "^9.19.0",
"typescript": "5.7.3"
},
"dependencies": {
"react": "^18.2.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
}
}
+17 -4
View File
@@ -1,7 +1,20 @@
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
children: React.ReactNode;
"use client";
import { ReactNode } from "react";
interface ButtonProps {
children: ReactNode;
className?: string;
appName: string;
}
export const Button = ({ children, ...rest }: ButtonProps) => {
return <button {...rest}>{children}</button>;
export const Button = ({ children, className, appName }: ButtonProps) => {
return (
<button
className={className}
onClick={() => alert(`Hello from your ${appName} app!`)}
>
{children}
</button>
);
};
+27
View File
@@ -0,0 +1,27 @@
import { type JSX } from "react";
export function Card({
className,
title,
children,
href,
}: {
className?: string;
title: string;
children: React.ReactNode;
href: string;
}): JSX.Element {
return (
<a
className={className}
href={`${href}?utm_source=create-turbo&utm_medium=basic&utm_campaign=create-turbo"`}
rel="noopener noreferrer"
target="_blank"
>
<h2>
{title} <span>-&gt;</span>
</h2>
<p>{children}</p>
</a>
);
}
+11
View File
@@ -0,0 +1,11 @@
import { type JSX } from "react";
export function Code({
children,
className,
}: {
children: React.ReactNode;
className?: string;
}): JSX.Element {
return <code className={className}>{children}</code>;
}
+5 -2
View File
@@ -1,5 +1,8 @@
{
"extends": "@repo/typescript-config/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
"compilerOptions": {
"outDir": "dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
@@ -0,0 +1,30 @@
import type { PlopTypes } from "@turbo/gen";
// Learn more about Turborepo Generators at https://turbo.build/repo/docs/core-concepts/monorepos/code-generation
export default function generator(plop: PlopTypes.NodePlopAPI): void {
// A simple generator to add a new React component to the internal UI library
plop.setGenerator("react-component", {
description: "Adds a new react component",
prompts: [
{
type: "input",
name: "name",
message: "What is the name of the component?",
},
],
actions: [
{
type: "add",
path: "src/{{kebabCase name}}.tsx",
templateFile: "templates/component.hbs",
},
{
type: "append",
path: "package.json",
pattern: /"exports": {(?<insertion>)/g,
template: ' "./{{kebabCase name}}": "./src/{{kebabCase name}}.tsx",',
},
],
});
}
@@ -0,0 +1,8 @@
export const {{ pascalCase name }} = ({ children }: { children: React.ReactNode }) => {
return (
<div>
<h1>{{ pascalCase name }} Component</h1>
{children}
</div>
);
};