papshmeare
2 years ago
3 changed files with 90 additions and 0 deletions
@ -0,0 +1,7 @@ |
|||||||
|
# Welcome to envSetupScript! |
||||||
|
This little script helps you save some time on setting up your JS environment for a fresh project. Inner workings are described via inline comments. |
||||||
|
## Contacts |
||||||
|
[Discord](https://discordapp.com/users/859153825075691530/) |
||||||
|
[Telegram](https://t.me/aleksei_baranovski_tln) |
||||||
|
## Authors |
||||||
|
Aleksei Baranovski |
@ -0,0 +1,12 @@ |
|||||||
|
{ |
||||||
|
"name": "setupscript", |
||||||
|
"version": "1.0.0", |
||||||
|
"description": "", |
||||||
|
"main": "index.js", |
||||||
|
"scripts": { |
||||||
|
"test": "echo \"Error: no test specified\" && exit 1" |
||||||
|
}, |
||||||
|
"keywords": [], |
||||||
|
"author": "Aleksei Baranovski", |
||||||
|
"license": "ISC" |
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
#!/bin/bash |
||||||
|
#apt-get install python-software-properties |
||||||
|
#curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash – |
||||||
|
#apt-get install nodejs |
||||||
|
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
||||||
|
# brew tap gitea/tap https://gitea.com/gitea/homebrew-gitea |
||||||
|
# brew install tea |
||||||
|
#tea login add |
||||||
|
echo Enter repository name |
||||||
|
|
||||||
|
#Ask the user for a new repository name |
||||||
|
read rname |
||||||
|
echo Enter authors |
||||||
|
#Ask the user for project authors |
||||||
|
read projectAuthors |
||||||
|
#Initialize an empty git repo |
||||||
|
git init |
||||||
|
#Create a first empty comment |
||||||
|
git commit -m "initial commit" --allow-empty |
||||||
|
#Add a dummy remote in order for tea to work(~eh) |
||||||
|
git remote add dummy http://localhost/dummy |
||||||
|
#Create a new repository on gitea |
||||||
|
tea repos create --name $rname |
||||||
|
#Remove the dummy remote |
||||||
|
git remote remove dummy |
||||||
|
#Add the actual remote |
||||||
|
git remote add $rname https://git.01.kood.tech/papshmeare/$rname.git |
||||||
|
#Set upstream so that push can be used without specifying the name |
||||||
|
git push -u $rname master |
||||||
|
#Initialize package.json |
||||||
|
npm init -y |
||||||
|
#Add authors to package.json |
||||||
|
npm pkg set author="$projectAuthors" |
||||||
|
#Create a separate folder for the source code |
||||||
|
mkdir src |
||||||
|
#Create index.js with a simple Hello world(For testing purposes) |
||||||
|
touch src/index.js && echo "console.log('Hello World!')" >> src/index.js |
||||||
|
#Create test.js with sample tests(for AVA testing purposes) |
||||||
|
touch src/test.js && echo -e "import test from 'ava';\ntest('foo', (t) => {\n t.pass();\n});\n\ntest('bar', async (t) => {\n const bar = Promise.resolve('bar');\n t.is(await bar, 'barr');\n});" >> src/test.js |
||||||
|
#Untrack /node_modules |
||||||
|
touch .gitignore && echo "/node_modules" >> .gitignore |
||||||
|
#Install prettier as a dev dependency |
||||||
|
npm install -D prettier eslint |
||||||
|
#Install prettier-plugin to work with ESLint |
||||||
|
npm install --save-dev eslint-plugin-prettier && npm install --save-dev --save-exact prettier |
||||||
|
npm install --save-dev eslint-config-prettier |
||||||
|
#Initialize empty prettier config |
||||||
|
touch .prettierrc && echo "{}" >> .prettierrc |
||||||
|
#Initialize eslintrc properties |
||||||
|
touch .eslintrc.yml && echo -e "extends:\n - eslint:recommended\n - plugin:prettier/recommended\nenv:\n node: true\n browser: true\n es2022: true\n\nplugins:\n - prettier\nrules:\n prettier/prettier: error\nparserOptions:\n ecmaVersion: latest\n sourceType: module |
||||||
|
" >> .eslintrc.yml |
||||||
|
#Create a linting script in package.json |
||||||
|
npm set-script lint "eslint src" |
||||||
|
#Install husky as a dev dependency, configure husky |
||||||
|
npm install husky -D |
||||||
|
npm set-script prepare "husky install" |
||||||
|
npm run prepare |
||||||
|
#Create a pre-commit script to force linting and tests to pass |
||||||
|
npx husky add .husky/pre-commit "npm run lint && npm run test" |
||||||
|
git add .husky/pre-commit |
||||||
|
#Add unit testing through AVA |
||||||
|
npm init ava |
||||||
|
#Set package.json attribute type to module |
||||||
|
npm pkg set type=module |
||||||
|
#Add git alias for a formatted git log command(git lg) |
||||||
|
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" |
||||||
|
#Add git alias for adding, commiting and pushing(git p) |
||||||
|
git config --global alias.p '!f() { git add . && git commit -am "$@" && git push origin HEAD; }; f' |
||||||
|
|
||||||
|
touch Readme.md && echo -e "# Welcome to $rname! \n## Contacts\n[Discord](https://discordapp.com/users/859153825075691530/)\n[Telegram](https://t.me/aleksei_baranovski_tln)\n## Authors\n$projectAuthors" >> Readme.md |
||||||
|
|
Loading…
Reference in new issue