#
# wget -O - https://bit.ly/32MCyOF | /bin/sh -
#
# Copyright (C) 2020 E01-AIO Automação Ltda.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# Author: Nelio Santos
#
if [ ! -d .git ] ; then
echo "Initializing your git repository..."
git init
fi
echo "Adding basic packages to your project..."
yarn add @types/node ts-node axios moment express \
jsonwebtoken winston mongoose amqplib ioredis \
@sentry/node body-parser morgan
echo "Adding developer dependencies to your project..."
yarn add -D typescript lint-staged prettier husky eslint rimraf \
eslint-config-prettier \
eslint-config-airbnb \
eslint-plugin-prettier \
eslint-plugin-import \
@typescript-eslint/parser \
@typescript-eslint/eslint-plugin \
eslint-import-resolver-typescript \
jest nodemon @types/jest @types/jest ts-jest typedoc \
@commitlint/cli @commitlint/config-conventional \
commitizen standard-version \
@types/express @types/jsonwebtoken @types/mongoose \
@types/amqplib supertest
export GIST_ROOT="https://gist.githubusercontent.com/nsfilho/92efb3388c2429b76c92523d93df4576/raw"
GIST_FILES=".eslintrc.js .npmignore .package.json.js .prettierrc.js autotest.js commitlint.config.js docker-compose.yml Dockerfile jest.config.js libclean.sh LICENSE README.md tsconfig.json typedoc.js"
# Granular downloads
downloadFile() {
path=$1
urlname=$2
if [ ! -f $path ] ; then
echo "Efetuando download: $path"
wget -O $path $GIST_ROOT/$urlname
fi
}
# Massive downloads
for file in $GIST_FILES ; do
echo "Downloading file..."
wget -O $file "$GIST_ROOT/$file"
done
if [ ! -f .gitignore ] ; then
wget -O .gitignore 'https://www.gitignore.io/api/node,macos'
fi
node .package.json.js
echo "Verificando outros requisitos..."
mkdir -p {src,migrations,assets,.github,.vscode}
mkdir -p .github/workflows
mkdir -p src/{components,constants,controllers,middlewares,services,tests}
mkdir -p src/services/{logger,mongo,rabbitmq,redis,sentry,express}
# Download all files
downloadFile "src/index.ts" "index.ts"
downloadFile "migrations/types.ts" "migration-types.ts"
downloadFile "migrations/template.ts" "migration-template.ts"
downloadFile ".github/workflows/main.yaml" "workflow-main.yaml"
downloadFile ".github/workflows/release.yaml" "workflow-release.yaml"
downloadFile ".vscode/typescript.code-snippets" "typescript.code-snippets"
downloadFile ".vscode/launch.json" "launch.json"
downloadFile ".vscode/settings.json" "settings.json"
downloadFile "src/components/generic.ts" "components-generic.ts"
downloadFile "src/constants/app.ts" "constants-app.ts"
downloadFile "src/constants/index.ts" "constants-index.ts"
downloadFile "src/constants/mongo.ts" "constants-mongo.ts"
downloadFile "src/constants/rabbitmq.ts" "constants-rabbitmq.ts"
downloadFile "src/constants/redis.ts" "constants-redis.ts"
downloadFile "src/constants/sentry.ts" "constants-sentry.ts"
downloadFile "src/controllers/default.ts" "controllers-defaut.ts"
downloadFile "src/controllers/error.ts" "controllers-error.ts"
downloadFile "src/middlewares/auth.ts" "middlewares-auth.ts"
downloadFile "src/middlewares/debug.ts" "middlewares-debug.ts"
downloadFile "src/services/logger/index.ts" "services-logger-index.ts"
downloadFile "src/services/mongo/index.ts" "services-mongo-index.ts"
downloadFile "src/services/mongo/migration.ts" "services-mongo-migration.ts"
downloadFile "src/services/rabbitmq/index.ts" "services-rabbitmq-index.ts"
downloadFile "src/services/redis/index.ts" "services-redis-index.ts"
downloadFile "src/services/sentry/index.ts" "services-sentry-index.ts"
downloadFile "src/services/express/index.ts" "services-express-index.ts"
downloadFile "src/services/express/index.test.ts" "services-express-index.test.ts"
downloadFile "src/tests/index.ts" "tests-index.ts"
downloadFile "src/tests/axios.ts" "tests-axios.ts"
downloadFile "src/tests/express.ts" "tests-express.ts"
downloadFile "src/types.ts" "types.ts"
# Adding ignoring more packages
echo "build" >> .gitignore
echo "docs" >> .gitignore
# Lib prepare
chmod +x libclean.sh
# Adding features for release
yarn commitizen init cz-conventional-changelog --yarn --dev --exact
echo "Formatting files to finalize script..."
yarn format