diff --git a/.changeset/red-rules-turn.md b/.changeset/red-rules-turn.md new file mode 100644 index 0000000000..becc31f97e --- /dev/null +++ b/.changeset/red-rules-turn.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": patch +--- + +Add more scripts in `package.json` diff --git a/cli/src/installers/tailwind.ts b/cli/src/installers/tailwind.ts index e692392823..c50ab68dc7 100644 --- a/cli/src/installers/tailwind.ts +++ b/cli/src/installers/tailwind.ts @@ -1,5 +1,6 @@ import path from "path"; import fs from "fs-extra"; +import { type PackageJson } from "type-fest"; import { PKG_ROOT } from "~/consts.js"; import { type Installer } from "~/installers/index.js"; @@ -31,8 +32,21 @@ export const tailwindInstaller: Installer = ({ projectDir }) => { const cssSrc = path.join(extrasDir, "src/styles/globals.css"); const cssDest = path.join(projectDir, "src/styles/globals.css"); + // add format:* scripts to package.json + const packageJsonPath = path.join(projectDir, "package.json"); + + const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson; + packageJsonContent.scripts = { + ...packageJsonContent.scripts, + "format:write": 'prettier --write "**/*.{ts,tsx,js,jsx,mdx}" --cache', + "format:check": 'prettier --check "**/*.{ts,tsx,js,jsx,mdx}" --cache', + }; + fs.copySync(twCfgSrc, twCfgDest); fs.copySync(postcssCfgSrc, postcssCfgDest); fs.copySync(cssSrc, cssDest); fs.copySync(prettierSrc, prettierDest); + fs.writeJSONSync(packageJsonPath, packageJsonContent, { + spaces: 2, + }); }; diff --git a/cli/template/base/package.json b/cli/template/base/package.json index e13a5485ef..fff75519f8 100644 --- a/cli/template/base/package.json +++ b/cli/template/base/package.json @@ -7,7 +7,11 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "lint:fix": "next lint --fix", + "check": "next lint && tsc --noEmit", + "preview": "next build && next start", + "typecheck": "tsc --noEmit" }, "dependencies": { "@t3-oss/env-nextjs": "^0.10.1",