neetob temp
The neetob
gem gives different commands for interacting with Github and Heroku instances of existing neeto projects.
Table of Contents
- Getting Started
- Installation
- Usage
- Working with GitHub
- Issues
- Labels
- Search
- Protect Branch
- Make PR
- Login
- Working with Heroku
- Config Vars
- Access
- Execute
- Working with Users
- Audit
- Commits
- Working with Make Repos Uptodate
- Working with local Repos
- ls
- 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.
neetob github issues list --count --state open --assignee none --apps "neeto-*-web"
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.
neetob github labels list --apps "neeto-*-web"
neetob github labels show --name priority --apps "neeto-*-web"
neetob github labels update --old-name "High Priority" --new-name \
"high-priority" --all-neeto-repos
neetob github labels upsert --all-neeto-repos
neetob github labels upsert --path ~/Desktop/labels.json --apps "neeto-*-web"
neetob github labels delete --labels "High Priority" "Priority 1" "bug" \
--apps "neeto-*-web"
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.
neetob github make-pr compliance-fix
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.
neetob heroku config_vars list --apps "neeto-*-production"
neetob heroku config_vars list --apps "neeto-*-production" --keys key1 key2 key3
neetob heroku config_vars list --apps "neeto-*-production" --path \
neetob/data/config-vars-list.json
neetob heroku config_vars audit --apps "neeto-*-production"
neetob heroku config_vars audit --path ~/Desktop/config.json --apps "neeto-*-production"
neetob heroku config_vars upsert --apps "neeto-*-staging"
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.
neetob heroku access list --apps "neeto-*-production"
neetob heroku access add --users oliver@bigbinary.com eve@bigbinary.com --apps "neeto-*-staging"
neetob heroku access remove --users oliver@bigbinary.com eve@bigbinary.com --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.
neetob heroku execute -c "heroku access" --apps "neeto-*-production"
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.
neetob users commits --author udai1931 --duration 6.months
neetob users commits --author udai1931 --duration 6.months --apps neeto-kb-web
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
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.
neetob local ls --apps "*"
neetob local ls --dir public --apps "*"
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.