GithubHelp home page GithubHelp logo

ivanilves / travelgrunt Goto Github PK

View Code? Open in Web Editor NEW
65.0 6.0 3.0 139 KB

navigate inside [mono]repos effortlessly!

License: Apache License 2.0

HCL 9.40% Go 83.00% Makefile 5.66% Shell 1.51% Dockerfile 0.24% Groovy 0.20%
devops git platform sre system-administration terraform terragrunt systems shell fatigue monorepo

travelgrunt's Introduction

codeclimate codecov

travelgrunt

Travel Terragrunt, Terraform and ... ANY [Git] repository tree with no stress, as a first class passenger! โœˆ๏ธ

travelgrunt alleviates the pain of hitting endless cd/<TAB> combos while navigating inside the repo.

๐Ÿ’ก Video with a brief introduction and a demo is available here ๐ŸŽฅ

How to use?

  • cd to the directory of your [locally cloned] Git repository;
  • run tg alias there ๐Ÿš€ ([optional] arguments are "path filter" matches);
  • use arrow keys to navigate the list and / key to search for specific items;

Configuration

๐Ÿ’ก If no configuration file found travelgrunt will assume repository having only Terragrunt projects inside.

Create .travelgrunt.yml file in the root path of your repository. Example config for a random monorepo:

rules:
  - prefix: vendor/
    negate: true
  - prefix: terragrunt/
    mode: terragrunt
  - prefix: code/
    name: '.*\.(go|js|css|html)$'
  - prefix: config/
    name: '*.yaml'

โฌ†๏ธ Config is essentially a list of sequentially applied path matching rules. Each rule can have these fields:

  • prefix - literal prefix to be matched against relative directory path;
  • name - a free form regular expression or a simple glob (name: '*.go') match applied to the file name;
  • mode - any matching behavior backed by a [custom logic] function from the mode package;
  • negate - boolean directive that reverses the meaning of the match, excluding the paths matched;

๐Ÿ’ก Even while developing travelgrunt itself we use it to navigate package directories of the application ๐ŸŽฉ

Override configured rules with arbitrary expression

You can search by the arbitrary expression instead of configured rules:

tg -x <EXPRESSION> [<match> <match2> ... <matchN>]

Shell aliases and functions

It is absolutely required to use zsh aliases or bash functions. Start from something like this:

ZSH

alias tg='_tg(){ travelgrunt -out-file ~/.tg-path ${@} && cd "$(cat ~/.tg-path)" }; _tg'
alias tt='_tt(){ travelgrunt -top -out-file ~/.tg-path && cd "$(cat ~/.tg-path)" }; _tt'

BASH

function tg() {
	travelgrunt -out-file ~/.tg-path ${@} && cd "$(cat ~/.tg-path)"
}

function tt() {
	travelgrunt -top -out-file ~/.tg-path && cd "$(cat ~/.tg-path)"
}

These lines are usually added to ~/.bashrc or ~/.zshrc file, depending on your system and shell of choice.

๐Ÿ’ก tt is a "convenience alias" that brings you to the top level path of your repository.

Why aliases?

Core feature of this program is the ability to change working directory while staying inside the current shell. This can not be done by the program itself, because of POSIX security limitations. Without instrumenting the shell with aliases travelgrunt will not work!

CTRL+C / CTRL+D behaviour

When key combinations CTRL+C or CTRL+D get pressed during the execution, following occures:

  • CTRL+C - program terminates with exit code 1, under the starting directory path;
  • CTRL+D - program terminates with exit code 0, under the directory path currently selected;

How to install? :neckbeard:

Install with homebrew:

brew tap ivanilves/tap
brew install ivanilves/tap/travelgrunt

Install latest binary with cURL + sh:

Install latest release binary into /usr/local/bin (default):

curl -s -f \
  https://raw.githubusercontent.com/ivanilves/travelgrunt/main/scripts/install-latest.sh | sh

Install latest release binary into /somewhere/else/bin:

curl -s -f \
  https://raw.githubusercontent.com/ivanilves/travelgrunt/main/scripts/install-latest.sh \
  | PREFIX=/somewhere/else sh

How to build? ๐Ÿšง

  • make dep - install/ensure dependencies;
  • make build - build the travelgrunt binary in cmd/travelgrunt path;
  • make install - [optional] install built travelgrunt binary under the ${PREFIX}/bin location;

How to release a new version? ๐Ÿ“ฆ

๐Ÿ’ก Make sure you have push permissions for this repository!

Run make release recipe, which will:

  • check, if you are on a main branch;
  • pull the latest main branch from remote;
  • calculate the next release version (update MAJOR.MINOR here if needed);
  • tag the branch tip with the version calculated and push tag to remote then;
  • GoReleaser will take care of everything else ๐Ÿ˜Ž

travelgrunt's People

Contributors

bmbferreira avatar davidilves avatar ivanilves avatar vonrabbe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

travelgrunt's Issues

Do we need a self-update command?

Definitely we should have support for version managers like ASDF #7 or traditional package managers like dpkg or rpm, but having a self-update command is a very convenient option as well. It can be a real code inside travelgrunt or a bash alias ๐Ÿ™‚

Add content search feature

Since we mostly operate on text files inside Git repositories, content search feature in some form would be handy.

Add rule loading from config file

Add support for rule loading from config file. We need to be able to change operation mode of travelgrunt without recompiling it ๐Ÿ™‚

Thank you!

Add non-repo "bookmarks" mode

Add repository-agnostic, filesystem "bookmarks" mode:

  • use global, ~/.travelgrunt.yml config file to store it;
  • use this file if outside of Git repo - just use travelgrunt to jump across different paths in filesystem;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.