Skip to content

Instantly share code, notes, and snippets.

@skapxd
Last active April 18, 2023 13:18
Show Gist options
  • Save skapxd/b6224ed1b71fac301c53546fb65cbf63 to your computer and use it in GitHub Desktop.
Save skapxd/b6224ed1b71fac301c53546fb65cbf63 to your computer and use it in GitHub Desktop.
Scaffold a typescript project quickly
#!/bin/bash
yarn init -y
yarn add dotenv express joi lodash morgan
yarn add -D nodemon ts-node types-installer typescript add-npm-scripts
yarn add-npm-scripts start "nodemon"
yarn add-npm-scripts build "tsc"
yarn types-installer
cat > nodemon.json <<EOL
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "node --inspect -r ts-node/register ./src/index.ts"
}
EOL
git init
cat > .gitignore <<EOL
node_modules
dist
yarn-error.log
init-ts-proyect.sh
EOL
cat > tsconfig.json <<EOL
{
"compilerOptions": {
"module": "CommonJS",
"target": "ES2020",
"noImplicitAny": false,
"strictNullChecks": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"#/*": [
"*"
]
},
},
"include": [
"src/**/*"
]
}
EOL
mkdir -p src
cat > src/index.ts <<EOL
console.log('hello world!');
EOL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment