Skip to content

Instantly share code, notes, and snippets.

@ilaborie
Created August 26, 2017 10:14
Show Gist options
  • Save ilaborie/171c18bd3882f2319612b384b8952277 to your computer and use it in GitHub Desktop.
Save ilaborie/171c18bd3882f2319612b384b8952277 to your computer and use it in GitHub Desktop.
Generate TS project
#!/usr/bin/env bash
APP=$1
# dir
echo "Create $APP folder"
mkdir $APP
pushd $APP
# Git
git init
git commit --allow-empty -m empty
# package.json
yarn init -y
# dependencies
yarn add -D typescript ts-node-dev tslint tslint-config-standard stylefmt stylelint stylelint-config-standard husky lint-staged prettier commitizen cz-conventional-changelog @types/node
# Start scripts
yarn add -D npe
npe scripts.start "ts-node-dev --respawn src/index.ts"
npe scripts.precommit "lint-staged"
npe scripts.format:ts "prettier --single-quote --trailing-comma --parser typescript --write"
npe scripts.format:style "stylefmt"
npe scripts.lint:style "stylelint --syntax=scss \"src/**/*.scss\""
npe scripts.lint:ts "tslint --type-check --project . --format codeframe"
yarn remove npe
# TypeScript Config
cat << EOF > tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true
}
}
EOF
# git config
cat << EOF > .gitignore
node_modules/
*.log
EOF
# tslint config
cat << EOF > tslint.json
{
"extends": "tslint-config-standard",
"rules": {
"prefer-const": true,
"ordered-imports": true
}
}
EOF
# stylelint config
cat << EOF > .stylelintrc
{
"extends": "tslint-config-standard"
}
EOF
# lint-stage config
cat << EOF > .lintstagedrc
{
"*.ts": [
"format:ts",
"tslint --fix --project .",
"tslint --type-check --project . --format codeframe",
"git add"],
"*.scss": [
"stylefmt",
"stylelint --syntax=scss --fix",
"git add" ],
}
EOF
# commit config
cat << EOF > .czrc
{
"path": "cz-conventional-changelog"
}
EOF
# Hello World
mkdir src
cat << EOF > src/index.ts
console.log( "Hello World !")
var x = [1,
2,
3,]
EOF
# Git
git add .
git commit -m 'chore: init projet'
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment