Development Environment
Serverless Development Environment for Python, Javascript/React and Node Developers (on OSX):
Install Prerequesits Package Manger Homebrew and CLI Tools:
xcode-select --install
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Runtime for Javascript and Python:
brew install node python3
Install Python and Javascript packages / Dependencies:
pip3 install virtualenv
npm install -g serverless create-react-app
Source: http://sourabhbajaj.com/mac-setup/Python/virtualenv.html
Additional tools to improve the developer experience:
brew cask install google-chrome
brew cask install visual-studio-code
brew cask install iterm2
brew cask install postman
brew install git
git config --global credential.helper osxkeychain
brew install git-secrets
Setup a template for git to prevent checking in credentials
Make a directory for the template:
mkdir ~/.git-template
Install the hooks in the template directory:
git secrets --install ~/.git-template
Tell git to use it:
git config --global init.templateDir '~/.git-template'
Install AWS patterns globally to be prevented to be checked in to git:
git secrets --register-aws --global
Check the list of secrets
git secrets
will scan for:git secrets --list
It should return something like:
ecrets.providers git secrets --aws-provider
secrets.patterns [A-Z0-9]{20}
secrets.patterns ("|')?(AWS|aws|Aws)?_?(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)("|')?\s*(:|=>|=)\s*("|')?[A-Za-z0-9/\+=]{40}("|')?
secrets.patterns ("|')?(AWS|aws|Aws)?_?(ACCOUNT|account|Account)_?(ID|id|Id)?("|')?\s*(:|=>|=)\s*("|')?[0-9]{4}\-?[0-9]{4}\-?[0-9]{4}("|')?
secrets.allowed AKIAIOSFODNN7EXAMPLE
secrets.allowed wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Now every time you run git init
or git clone
, your hooks will be copied into the .git
directory of your freshly created repo. If you don’t want to set the template globally, you can use it as needed with git init --template ’~/.git-template’
.
That covers new repo creation, and cloning, but we haven’t addressed the problem of existing repos that weren’t created with the template. Here we have a couple options:
git init
is a non-destructive operation, so feel free to run it in existing repos. It’s safe, and will retroactively apply the template you specify.
OR
If you want to go “all in” and ensure that every repo has the proper hooks, here’s a script that will recursively walk a directory, such as ~/Projects
and run git secrets --install
in all repos.
Setup visual studio code
List all my installed extensions:
code --list-extensions
HookyQR.beautify
PeterJausovec.vscode-docker
dbaeumer.vscode-eslint
dzannotti.vscode-babel-coloring
formulahendry.auto-close-tag
jebbs.plantuml
magicstack.MagicPython
ms-python.python
msjsdiag.debugger-for-chrome
taichi.react-beautify
tht13.python
tushortz.python-extended-snippets
vscodevim.vim
yzhang.markdown-all-in-one
Create project and initialise repositories
mkdir apis-api
cd apis-api
git init
git remote add origin https://github.com/denseidel/apis-api.git
npm init
git add .
git commit -am "add package.json and ignore local python files"
git push --set-upstream origin master
Code: https://github.com/denseidel/apis-api/commit/ecc27aaf1f7a714938d99f1b5d656a67376c934b
Documentation
Use Gitbooks:
Install gitbook CLI:
npm install -g gitbook-cli
Initialize:
gitbook init
Generate output to custom folder
gitbook build . docs
Git Knowledge
Use branches and if needed squash all commits related to a single issue into one commit
Modify the last two commits:
git rebase -i HEAD~2
Or if they are the last two:
https://stackoverflow.com/a/24690646/1929968
git reset --soft "HEAD^"
git commit --amend
git push -f
Use git stash to switch change between branches - https://www.youtube.com/watch?v=KLEDKgMmbBI
# stash current state
git stash save "Worked on get identities/{identityId}"
# apply current stage (e.g. in other branch) but keep stash
git stash add
# apply current state and delete stash
git stash pop
Development Pipeline:
Use CircleCI as a SaaS as Pipeline:
Add the git repo to it:
Setup a project as described (e.g. add the folder
.circleci
with theconfig.yml
file)
Link to config.yml file
for containers
for serverless
Last updated