neetob temp
The neetob
gem gives different commands for interacting with Github and Heroku instances of existing neeto projects.
Table of Contents
- Getting Started
- Usage
- Working with GitHub
- Working with Heroku
- Working with Users
- Working with Make Repos Uptodate
- Working with local Repos
- Testing
Getting started
Installation
Clone the repository onto your system using the following command:
git clone https://github.com/bigbinary/neetob.git
Navigate to the root of the application directory.
cd neetob
To set up neetob
, execute the below command from the root of the application directory.
bin/setup
Usage
Utilize the help
keyword to access a comprehensive list of all the available commands and options.
neetob help
Commands:
neetob github # Interact with any resource in Github
neetob help [COMMAND] # Describe available commands or one specific command
neetob heroku # Interact with any resource in Heroku
neetob users # Interact with the contributors of neeto apps
neetob make-repos-uptodate # Update all neeto repos
Options:
[--sandbox] # All the commands in sandbox mode will run only on the "neeto-dummy" app.
By default, all commands will be executed in non-sandbox mode.
Useful command-line options
Option | Meaning |
---|---|
--apps | Target app names |
--sandbox | Sandbox mode |
--no-sandbox | Non-Sandbox mode |
--help | Provides information on a command |
Note: The commands within neetob
should be used with caution, as improper usage may result in unintended consequences, and some actions may not be reversible.
Working with GitHub
Efficiently gain access to a comprehensive list of all the available subcommands for the github
command by utilizing the help
keyword.
neetob github help
Issues
The issues
command offers valuable insights into GitHub issues.
# To efficiently list and count all the open issues that are currently unassigned
neetob github issues list --count --state open --assignee none --apps "neeto-*-web"
# To list, count and filter all unassigned open issues that are labeled as "bug"
neetob github issues list --count --label bug --state open --assignee none --apps "neeto-*-web"
Labels
The labels
command provides an interface for interacting with Github labels.
# The `list` command lists the details of all the labels in the Github repo
neetob github labels list --apps "neeto-*-web"
# The `show` command gives the details for a specific label in the Github repo
neetob github labels show --name priority --apps "neeto-*-web"
# The `update` command updates the name of a label
neetob github labels update --old-name "High Priority" --new-name \
"high-priority" --all-neeto-repos
# The `upsert` command updates and inserts all the labels mentioned in the
# JSON file "data/github-labels.json"
neetob github labels upsert --all-neeto-repos
# The `upsert` command accepts a different JSON file using `path` option
neetob github labels upsert --path ~/Desktop/labels.json --apps "neeto-*-web"
# The `delete` command deletes the given labels from the Github repos
neetob github labels delete --labels "High Priority" "Priority 1" "bug" \
--apps "neeto-*-web"
# The `delete_all` command deletes all the labels from the Github repos
neetob github labels delete_all --apps "neeto-*-web"
Check out the default labels file for the required JSON file structure.
All neeto repos list is maintained at neeto_compliance.
Search
Easily search for keywords across multiple neeto projects within specified files by utilizing the search
command.
neetob github search --keyword neeto --path README.md --apps "neeto-*-web"
Protect branch
Update branch protection rules in neeto repos by using the protect_branch
command.
neetob github protect_branch --branch main --apps neeto-dummy
By default, this file will be used for updating the branch protection rules.
The protect_branch
command can also be used with a different JSON file using path
option.
For example, assume we have a file named branch-protection-rules.json
on the Desktop
with the following rules:
{
"required_conversation_resolution": true,
"has_required_deployments": true
}
To update the above-mentioned branch protection rules for the main
branch of all the neeto products, use the following command:
neetob github protect_branch --branch main --path ~/Desktop/branch-protection-rules.json \
--apps neeto-dummy
We can also use the --all-neeto-repos
option with the above mentioned command so that the
branch protection rules can be updated for
all neeto repos.
neetob github protect_branch --branch main --path ~/Desktop/branch-protection-rules.json \
--all-neeto-repos
Note: Unfortunately, utilizing the Github API, we are unable to update the Require deployments to succeed before merging
rule, as it is currently not defined as a parameter within the API. For further information on available options to update different branch protection rules, kindly refer to the official Github documentation.
Make PR
The make-pr
command creates pull requests across Github repos.
# The `compliance-fix` command executes a `bundle` inside all repos and creates a PR
neetob github make-pr compliance-fix
# The `script` command runs the given script for each product and create a PR
neetob github make-pr script --path ~/Desktop/fix-folders.sh --branch "neetob-test" \
--title "PR title"
Login
Authenticate through your browser and update your Github access token by utilizing the login
command.
neetob github login
Working with Heroku
Utilize the help
command to list all the available subcommands under the Heroku module for interacting with the Heroku resources.
neetob heroku help
Config vars
The config_vars
command is useful to interact with Heroku config variables.
# The `list` command lists all the Heroku config variables
neetob heroku config_vars list --apps "neeto-*-production"
# We can list specific Heroku config variables using `keys` option
neetob heroku config_vars list --apps "neeto-*-production" --keys key1 key2 key3
# We can also use a file to specify required config vars for `list` command
# Checkout the `data/config-vars-list.json` file for the required structure.
neetob heroku config_vars list --apps "neeto-*-production" --path \
neetob/data/config-vars-list.json
# The `audit` command will check the config variables against the JSON file named as
# `required-config-vars.json` that is present inside the `data` directory at the root of
# installed `neetob` gem.
neetob heroku config_vars audit --apps "neeto-*-production"
# The `audit` command can also be used with a different JSON file using `--path` option.
neetob heroku config_vars audit --path ~/Desktop/config.json --apps "neeto-*-production"
# The `upsert` command adds or updates the config variables from the
# `data/config-vars-upsert.json` file present at the root of installed `neetob` gem.
neetob heroku config_vars upsert --apps "neeto-*-staging"
# The `remove` command is used to delete `config_vars`.
neetob heroku config_vars remove --keys=TEST_KEY_1 TEST_KEY_2 --apps "neeto-*-staging"
We can use a custom JSON file with upsert
command using the path
option.
For example, assume we have a file named config.json
on the Desktop, like so:
{
"NEETO_WIDGET_API_KEY": "jh4c1SC5cS5BvRbcBk4LD",
"NEETO_KB_API_KEY": "Lxh7vUKkRewfxSg4dg834",
"NEETO_CHAT_API_KEY": "sYnMTSCWLxkNbkHRXL1Xtd"
}
To update the above-mentioned config variables to all staging apps, we can use the upsert command like so:
neetob heroku config_vars upsert --path ~/Desktop/config.json --apps "neeto-*-staging"
The upsert
command can also be used to update and insert project-specific config variables.
For example, assume we have a file named config.json
on the Desktop
with the following properties:
{
"neeto-chat-web-staging": {
"NEETO_WIDGET_API_KEY": "jh4c1SC5cS5BvRbcBk4LD"
},
"neeto-testify-web-production": {
"NEETO_KB_API_KEY": "Lxh7vUKkRewfxSg4dg834"
},
"neeto-desk-web-staging": {
"NEETO_CHAT_API_KEY": "sYnMTSCWLxkNbkHRXL1Xtd"
}
}
To update the above-mentioned config variables under the defined project, we can use the upsert command like so:
neetob heroku config_vars upsert --path_with_project_keys ~/Desktop/config.json
Access
We can list, add, and remove users from multiple Heroku apps using the access
command.
# The `list` command retrieves a list of all the users from Heroku apps.
neetob heroku access list --apps "neeto-*-production"
# Add new users to the Heroku apps.
neetob heroku access add --users [email protected] [email protected] --apps "neeto-*-staging"
# Remove the users from the Heroku apps.
neetob heroku access remove --users [email protected] [email protected] --apps \
"neeto-*-staging"
Execute
Utilize the execute
command to run a Heroku CLI command or a Rails console command for multiple neeto apps in one go.
# We can check who has access to the neeto Heroku apps like so:
neetob heroku execute -c "heroku access" --apps "neeto-*-production"
# We can run a command in the Rails console for different neeto Heroku apps like so:
neetob heroku execute -c "Sidekiq::Cron::Job.destroy \"server_side_worker\"" --apps \
"neeto-*-staging" --rails
Working with users
Using the users
command, we can interact with the contributors of neeto applications.
Audit
The audit
command enables the ability to comprehensively audit contributors across all neeto applications by providing functionality to check for contributors with multiple emails and users with third-party domain emails.
This command will search and use the neeto repos in the current working directory.
To fetch and update all neeto repos execute make_repos_uptodate command before the audit
command.
neetob users audit
Commits
Using commits
command we can list the commits for a user in a defined duration.
# The below mentioned command will open a list of all the commits across neeto
# product repos made by "udai1931" in the duration of last 6 months.
neetob users commits --author udai1931 --duration 6.months
# We can list commits for a specific product using `--apps` option.
neetob users commits --author udai1931 --duration 6.months --apps neeto-kb-web
# We can list commits for all neeto repos using the `--all-neeto-repos` option.
neetob users commits --author udai1931 --duration 6.months --all-neeto-repos
Working with Make Repos Uptodate
Using the make_repos_uptodate
command, we can uptodate all neeto repos.
The list of neeto repos is picked up from neeto_compliance.
neetob make_repos_uptodate
# We have a `--all-neeto-repos` option for this command too so that we can
# fetch and update all the neeto repos in the current working directory.
neetob make_repos_uptodate --all-neeto-repos
Executing the above mentioned command will check and clone all the missing neeto repos in the current working directory and will update all of them to the latest version. After the execution of command the directories will look something like this:
neeto-chat-web
neeto-desk-web
neeto-kb-web
Working with local Repos
Using the local
command, we can interact with the local neeto repos.
ls
The ls
command can list the files from all the local neeto repos.
This command will search and use the neeto repos in the current working directory.
To fetch and update all neeto repos execute make_repos_uptodate command before the ls
command.
# The `ls` command will list all the files in the root directory of neeto repos.
neetob local ls --apps "*"
# The `ls` command can also list files in a specific directory using the
# `--dir` option.
neetob local ls --dir public --apps "*"
# We can also list files in a nested directory.
neetob local ls --dir app/controllers --apps "*"
Testing
For testing github
commands use - neeto-dummy repo.
For testing heroku
commands use - neeto-dummy app.
Note: Contact your respective Team Lead if you don't have access.