Posts

Showing posts from November, 2020

nodeenv: Isolated node runtimes on MacOS

nodeenv allows to create isolated node runtimes per project which resembles to virtual environments in python world. In enterprise projects, where multiple projects are built against different versions of node runtime and dependencies, it is advantageous to have nodeenv to install multiple versions of node runtimes at project level. Install nodeenv brew install nodeenv or pip install nodeenv List available node runtime versions nodeenv --list Create latest node version as virtual environment nodeenv env Create a specific node version as virtual environment nodeenv --node=14.15.0 env Activate a virtual environment source env/bin/activate Verify node and npm version node --version npm --version Install a package scoped to the virutal environment npm install -g cypress Deactivate or exit from virtual environment deactivate_node Delete the virtual environment rm -rf env

GitOps - Viewing and Creating git tags

In a team following continuous delivery based on git tags or otherwise popularly known as GitOps, there will be a frequent need to list the existing tags in a repository in chronological order so that a new tag can be created based on recent commit (HEAD) from master / main branch. The following chained command will list all the remote tags in chronological order along with latest commit, so that new release tags can be quickly created through command line. List all annotated tags name with the commit SHA in chronological order along with recent commit id git fetch origin && git checkout master && git pull && git ls-remote --tags --sort=creatordate origin && git log -n 1 Create a new tag based on master / main branch or specific commit SHA and push the tag to remote server tag_name="production-v1.0" && git tag -a $tag_name master -m "Production version 1.0" && git push origin $tag_name

Creating python virtual environments on Mac OS with pyenv

Using pyenv Install pyenv through homebrew: brew install pyenv List installed versions of python: pyenv versions List available versions of python that can be installed: pyenv install --list Virtual environment for python 3: Install a specific version of python: pyenv install 3.9.0 NOTE for Big Sur (MacOS 11) users: If the install command fails, then try the command as SYSTEM_VERSION_COMPAT=1 pyenv install 3.9.0 Switch to specific version of python in local terminal window: pyenv local 3.9.0 Switch to specific version of python globally: pyenv global 3.9.0 Switch to specific version of python using environment variable: export PYENV_VERSION=3.9.0 Get pyenv root directory: pyenv root Access the python installation: pyenv exec python --version Create a virtual environment from specific python version: pyenv exec python -m venv .venv Source the virtual environment source .venv/bin/activate Virtual environment for python 2: Install a specific version of python: pyenv install 2.7.18 Switch