-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode-init-typescript
More file actions
105 lines (90 loc) · 2.09 KB
/
Copy pathnode-init-typescript
File metadata and controls
105 lines (90 loc) · 2.09 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
#!/usr/bin/env bash
#
# This bash script automates the creation of a new TypeScript node.js project with NPM.
set -e # Exit on error
if [ $# -ne 0 ]; then
echo "Usage: node-init-typescript"
echo "Initializes a new TypeScript Node.js project."
exit 1
fi
echo "*** Creating git repo ..."
git init
git commit --allow-empty -m "New repo"
echo
echo "*** Creating .gitignore ..."
npx gitignore node
cat >> .gitignore << 'EOF'
dist/
# Claude AI
.claude/
# VS Code
.vscode/
EOF
git add --all
git commit -m "Added TypeScript default .gitignore"
echo
echo "*** Creating MIT license ..."
npx license MIT
git add --all
git commit -m "Added MIT License"
echo
echo "*** Creating default README.md ..."
cat > README.md << EOF
# $(basename "$PWD")
EOF
git add --all
git commit -m "Added default README.md"
echo
echo "*** Initializing node.js project ..."
npm init -y
npm install
git add --all
git commit -m "Added default package.json and package-lock.json"
echo
echo "*** Installing TypeScript dependencies ..."
npm install --save-dev typescript @types/node tsx vitest
echo
echo "*** Creating tsconfig.json ..."
cat > tsconfig.json << 'EOF'
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
EOF
echo
echo "*** Creating project structure ..."
mkdir -p src/lib # git does not track empty directories; add files here as needed
echo
echo "*** Updating package.json scripts ..."
npm pkg set scripts.build="tsc"
npm pkg set scripts.test="vitest"
npm pkg set scripts.test:run="vitest --run"
echo
echo "*** Creating .vscode/launch.json ..."
mkdir -p .vscode
cat > .vscode/launch.json << 'EOF'
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug current file",
"runtimeExecutable": "tsx",
"runtimeArgs": ["${file}"],
"skipFiles": ["<node_internals>/**"]
}
]
}
EOF
git add --all
git commit -m "Added TypeScript configuration"