-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateProjectReact.sh
More file actions
151 lines (129 loc) · 5.55 KB
/
generateProjectReact.sh
File metadata and controls
151 lines (129 loc) · 5.55 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Cores para o texto
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
NC='\033[0m' # No Color
timestamp=$(date +%s)
nameProject1="new_project_"
nameProject="${nameProject1}${timestamp}"
# echo -e " ${Red}Criar pasta do projeto"
# echo -e " ${Purple}Criar ficheiro de inicio de projeto"
# echo -e " ${Blue}Instalar dependencias${NC}"
# mkdir "$nameProject" &&
npx create-react-app "$nameProject" --use-npm --template typescript -y &&
cd "$nameProject" &&
npm init -y &&
npm i -g eslint &&
npm i -D git-commit-msg-linter &&
# npm i -D typescript @types/node &&
npm i -D eslint-config-standard-with-typescript eslint-plugin-import eslint-plugin-promise &&
###### npm i -D eslint-plugin-standard ######## This package has been deprecated ###############
npm i -D @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-node &&
#npm i -D eslint@6 eslint-config-standard-with-typescript@11 eslint-plugin-import eslint-plugin-promise eslint-plugin-standard @typescript-eslint/eslint-plugin eslint-plugin-node --legacy-peer-deps &&
npm i -D lint-staged husky &&
npm i -D jest &&
npm i -D ts-jest @types/jest &&
npm i -D faker @types/faker
# npx ts-jest config:init
#npm i -D jest@25 @types/jest ts-jest@25 --legacy-peer-deps
echo -e " ${Yellow}Trocar texto do ficheiro package.json"
# echo -e " ${Red}este comando só esta preparado para Mac Os"
# Trocar text do ficheiro
filename="package.json"
search="eject\": \"react-scripts eject"
#search='echo \\"Error: no test specified\\" && exit 1'
echo -e " ${search}"
replace="eject\": \"react-scripts eject\", \"lint:fix\": \"eslint '.\/src\/**\/*.{ts,tsx}' --fix"
#replace="jest"
#sed -i '' "s/$search/$replace/g" $filename
sed -i '' "s/$search/$replace/g" $filename
echo -e " ${Blue}Alterar o ficheiro tsconfig.json"
search_1="jsx\": \"react-jsx\""
replace_1="jsx\": \"react\", \"rootDir\": \"src\", \"baseUrl\": \"src\", \"paths\": { \"@\\/\*\": [\"\*\"] }"
filename_1="tsconfig.json"
sed -i '' "s/$search_1/$replace_1/g" $filename_1
# mkdir "src"
echo -e " ${Purple}Criar ficheiro .gtiignore"
touch .gitignore
echo "node_modules" >> .gitignore
echo ".vscode" >> .gitignore
echo "coverage" >> .gitignore
# echo -e " ${Green}Criar ficheiro tsconfig.json"
# touch tsconfig.json
# echo '{' >> tsconfig.json
# echo ' "compilerOptions": {' >> tsconfig.json
# echo ' "target": "es5",' >> tsconfig.json
# echo ' "lib": [' >> tsconfig.json
# echo ' "dom",' >> tsconfig.json
# echo ' "dom.iterable",' >> tsconfig.json
# echo ' "esnext",' >> tsconfig.json
# echo ' ],' >> tsconfig.json
# echo ' "esModuleInterop": true,' >> tsconfig.json#
# echo ' "module": "esnext",' >> tsconfig.#
# echo ' "moduleResolution": "node",' >> tsconfig.json#
# echo ' "jsx": "react",' >> tsconfig.json#
# echo ' "rootDir": "src",' >> tsconfig.json
# echo ' "baseUrl": "src",' >> tsconfig.json
# echo ' "allowJs": true,' >> tsconfig.json#
# echo ' "skipLibCheck": true,' >> tsconfig.json#
# echo ' "allowSyntheticDefaultImports": true,' >> tsconfig.json#
# echo ' "strict": true,' >> tsconfig.json#
# echo ' "forceConsistentCasingInFileNames": true,' >> tsconfig.json#
# echo ' "resolveJsonModule": true,' >> tsconfig.json#
# # echo ' "isolatedModules": true,' >> tsconfig.json#
# echo ' "noEmit": true,' >> tsconfig.json#
# echo ' },' >> tsconfig.json
# echo ' "include": [' >> tsconfig.json
# echo ' "src"' >> tsconfig.json
# echo ' ]' >> tsconfig.json
# echo '}' >> tsconfig.json
touch .eslintrc.json
echo '{' >> .eslintrc.json
echo ' "extends": "standard-with-typescript",' >> .eslintrc.json
echo ' "parserOptions": {' >> .eslintrc.json
echo ' "project": "tsconfig.json"' >> .eslintrc.json
echo ' },' >> .eslintrc.json
echo ' "rules": {' >> .eslintrc.json
echo ' "@typescript-eslint/consistent-type-definitions": "off",' >> .eslintrc.json
echo ' "@typescript-eslint/strict-boolean-expressions": "off",' >> .eslintrc.json
echo ' "@typescript-eslint/explicit-member-accessibility": 0,' >> .eslintrc.json
echo ' "@typescript-eslint/explicit-function-return-type": 0' >> .eslintrc.json
echo ' }' >> .eslintrc.json
echo '}' >> .eslintrc.json
touch .eslintignore
echo "node_modules" >> .eslintignore
echo ".vscode" >> .eslintignore
echo "coverage" >> .eslintignore
echo "src/reportWebVitals.ts" >> .eslintignore
echo "src/react-app-env.d.ts" >> .eslintignore
touch .lintstagedrc.json
echo '{' >> .lintstagedrc.json
echo ' "*.{ts,tsx}": [' >> .lintstagedrc.json
echo " \""eslint "'src/**'" --fix\""" >> .lintstagedrc.json
echo ' ]' >> .lintstagedrc.json
echo '}' >> .lintstagedrc.json
touch .huskyrc.json
echo '{' >> .huskyrc.json
echo ' "hooks": {' >> .huskyrc.json
echo ' "pre-commit": "lint-staged"' >> .huskyrc.json
echo ' }' >> .huskyrc.json
echo '}' >> .huskyrc.json
touch jest.config.js
echo "module.exports = {" >> jest.config.js
echo " roots: ['<rootDir>/src']," >> jest.config.js
echo " collectCoverageFrom: [" >> jest.config.js
echo " '<rootDir>/src/**/*.{ts,tsx}'" >> jest.config.js
echo " ]," >> jest.config.js
echo " coverageDirectory: 'coverage'," >> jest.config.js
echo " testEnvironment: 'node'," >> jest.config.js
echo " transform: {" >> jest.config.js
echo " '.+\\\\.ts$': 'ts-jest'" >> jest.config.js
echo " }" >> jest.config.js
echo "}" >> jest.config.js
eslint './src/**/*.{ts,tsx}' --fix