From 1567a481d51eff4fda60dae094775d76ac273863 Mon Sep 17 00:00:00 2001 From: immi Date: Wed, 16 Oct 2024 09:05:26 +0500 Subject: [PATCH 1/6] add more `scripts` `lint:fix` `check` `preview` `typecheck` `format:write` `format:check` --- cli/template/base/package.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cli/template/base/package.json b/cli/template/base/package.json index e13a5485ef..6334a91933 100644 --- a/cli/template/base/package.json +++ b/cli/template/base/package.json @@ -7,7 +7,13 @@ "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", + "format:write": "prettier --write \"**/*.{ts,tsx,js,jsx,mdx}\" --cache", + "format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,mdx}\" --cache" }, "dependencies": { "@t3-oss/env-nextjs": "^0.10.1", @@ -28,4 +34,4 @@ "eslint-config-next": "^14.2.4", "typescript": "^5.5.3" } -} +} \ No newline at end of file From f5d581ca9025020f05e9a706e8dd233c60741dd5 Mon Sep 17 00:00:00 2001 From: immi Date: Wed, 16 Oct 2024 12:39:16 +0500 Subject: [PATCH 2/6] add format:* scripts via `tailwind.ts` --- cli/src/installers/tailwind.ts | 15 +++++++++++++++ cli/template/base/package.json | 4 +--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cli/src/installers/tailwind.ts b/cli/src/installers/tailwind.ts index e692392823..60b315d477 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,22 @@ 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 6334a91933..9f241695c6 100644 --- a/cli/template/base/package.json +++ b/cli/template/base/package.json @@ -11,9 +11,7 @@ "lint:fix": "next lint --fix", "check": "next lint && tsc --noEmit", "preview": "next build && next start", - "typecheck": "tsc --noEmit", - "format:write": "prettier --write \"**/*.{ts,tsx,js,jsx,mdx}\" --cache", - "format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,mdx}\" --cache" + "typecheck": "tsc --noEmit" }, "dependencies": { "@t3-oss/env-nextjs": "^0.10.1", From d25aff9ff323b566dca9d61862537f7c94f86618 Mon Sep 17 00:00:00 2001 From: immi Date: Wed, 16 Oct 2024 12:47:08 +0500 Subject: [PATCH 3/6] up: scripts quotations --- cli/src/installers/tailwind.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/installers/tailwind.ts b/cli/src/installers/tailwind.ts index 60b315d477..9b7d620c6e 100644 --- a/cli/src/installers/tailwind.ts +++ b/cli/src/installers/tailwind.ts @@ -38,8 +38,8 @@ export const tailwindInstaller: Installer = ({ projectDir }) => { 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", + "format:write": 'prettier --write "**/*.{ts,tsx,js,jsx,mdx}" --cache', + "format:check": 'prettier --check "**/*.{ts,tsx,js,jsx,mdx}" --cache', }; fs.copySync(twCfgSrc, twCfgDest); From 165297bf65637cbdbb1a30b9fbb92a8048661f23 Mon Sep 17 00:00:00 2001 From: immi Date: Wed, 16 Oct 2024 16:12:40 +0500 Subject: [PATCH 4/6] format `tailwind.ts` --- cli/src/installers/tailwind.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cli/src/installers/tailwind.ts b/cli/src/installers/tailwind.ts index 9b7d620c6e..c50ab68dc7 100644 --- a/cli/src/installers/tailwind.ts +++ b/cli/src/installers/tailwind.ts @@ -32,15 +32,15 @@ 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"); + // add format:* scripts to package.json + const packageJsonPath = path.join(projectDir, "package.json"); - const packageJsonContent = fs.readJSONSync(packageJsonPath) as PackageJson; - packageJsonContent.scripts = { - ...packageJsonContent.scripts, + 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); @@ -49,5 +49,4 @@ export const tailwindInstaller: Installer = ({ projectDir }) => { fs.writeJSONSync(packageJsonPath, packageJsonContent, { spaces: 2, }); - }; From 29b7590f8e3438df138741ed8342181ee452ce8c Mon Sep 17 00:00:00 2001 From: immi Date: Wed, 16 Oct 2024 16:19:36 +0500 Subject: [PATCH 5/6] format --- cli/template/base/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/template/base/package.json b/cli/template/base/package.json index 9f241695c6..fff75519f8 100644 --- a/cli/template/base/package.json +++ b/cli/template/base/package.json @@ -32,4 +32,4 @@ "eslint-config-next": "^14.2.4", "typescript": "^5.5.3" } -} \ No newline at end of file +} From a18e00ede7496e9667203ba88a23b5fa6438d857 Mon Sep 17 00:00:00 2001 From: immi Date: Wed, 16 Oct 2024 16:57:32 +0500 Subject: [PATCH 6/6] chore: add changeset --- .changeset/red-rules-turn.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/red-rules-turn.md 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`