-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
83 lines (83 loc) · 3.18 KB
/
setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const { execSync } = require("child_process");
const fs = require("fs");
const { setJsonFileProps } = require("./lib/setJsonFileProps.js");
const { getJsonFileProp } = require("./lib/getJsonFileProp");
const gitIgnore = fs.readFileSync(".gitignore", { encoding: "utf8" });
const updatedGitIgnore = `${gitIgnore}\nbootstrap-next-typescript`;
fs.writeFileSync(".gitignore", updatedGitIgnore);
execSync("rm -f .eslintrc.json eslint.config.mjs tailwind.config.ts src/app/page.tsx src/app/layout.tsx src/app/globals.css");
execSync("mkdir -p src src/hooks src/contexts src/ui src/lib src/types src/pages src/pages/api");
execSync("cp -r ./bootstrap-next-typescript/setup/* .");
execSync("cp -r ./bootstrap-next-typescript/setup/.vscode .");
execSync("cp ./bootstrap-next-typescript/setup/.env.development .");
execSync("cp ./bootstrap-next-typescript/setup/eslint.config.mjs .");
execSync("cp ./bootstrap-next-typescript/setup/.lintstagedrc .");
execSync("yarn add lodash dotenv ts-node clsx @heroicons/react");
execSync("yarn add -D install-peerdeps cross-env husky lint-staged");
execSync("yarn install-peerdeps -D eslint-config-airbnb --yarn");
// https://github.com/iamturns/eslint-config-airbnb-typescript#setup
execSync("yarn add -D eslint-config-airbnb-typescript @typescript-eslint/eslint-plugin @typescript-eslint/parser");
execSync("yarn add -D @tailwindcss/forms @tailwindcss/typography");
execSync("yarn add -D jest jest-environment-jsdom eslint-plugin-testing-library @types/jest @testing-library/react @testing-library/jest-dom @testing-library/user-event @testing-library/dom @types/lodash");
setJsonFileProps({
filePath: "package.json",
propsPath: "scripts",
updatedProps: {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint -d .",
"lint:fix": "next lint -d . --fix",
"update-version": "node scripts/update-version.js",
"test": "yarn test:fe && yarn test:be",
"test:fe": "jest -c jest-frontend.config.js --passWithNoTests --coverage",
"test:be": "jest -c jest-backend.config.js -i src/pages/api/ --passWithNoTests --coverage",
}
})
setJsonFileProps({
filePath: "package.json",
propsPath: "devDependencies",
updatedProps: {
...getJsonFileProp({
filePath: "package.json",
propsPath: "devDependencies",
}),
"eslint": undefined,
}
})
setJsonFileProps({
filePath: "tsconfig.json",
propsPath: "include",
updatedProps: [
"next-env.d.ts",
"**/*.js",
"**/*.mjs",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
]
})
setJsonFileProps({
filePath: "tsconfig.json",
propsPath: "ts-node",
updatedProps: {
"compilerOptions": {
"module": "CommonJS"
}
}
})
setJsonFileProps({
filePath: "tsconfig.json",
propsPath: "exclude",
updatedProps: ["node_modules", "bootstrap-next-typescript"]
})
execSync("yarn add -D eslint");
execSync("rm -rf node_modules yarn.lock");
execSync("yarn");
execSync("yarn lint:fix");
execSync("yarn husky");
execSync("echo \"npx lint-staged && yarn test\" >> .husky/pre-commit");
execSync("echo \"yarn update-version && git add package.json\" >> .husky/pre-commit");
execSync("git reset");
execSync("git add .");
execSync("git commit -m 'arch: bootstrap-next-typescript'");