Skip to content

Commit

Permalink
feat: add more scripts (#1997)
Browse files Browse the repository at this point in the history
  • Loading branch information
programming-with-ia authored Oct 16, 2024
1 parent 43f77ad commit fe85a23
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/red-rules-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": patch
---

Add more scripts in `package.json`
14 changes: 14 additions & 0 deletions cli/src/installers/tailwind.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
});
};
6 changes: 5 additions & 1 deletion cli/template/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit fe85a23

Please sign in to comment.