herokutools v0.3.5
Heroku Tools
A CLI Wrapper for Everyday Commands
herokutools is a command-line interface (CLI) wrapper designed to simplify and streamline the process of interacting with your Heroku app. This tool provides a set of easy-to-use commands that help you interact with your Heroku apps more efficiently.
Features
- Fetch logs for your Heroku apps with a single command.
- Support for multiple Heroku apps through environment variables.
- Easy setup and installation.
- Built with TypeScript and Commander.js for robust and type-safe command handling.
Prerequisites
Before using herokutools, ensure that you have the following:
- A Heroku account. If you don't have one, you can sign up at Heroku.
- At least one Heroku app. You can create a new app using the Heroku Dashboard or the Heroku CLI.
Without a Heroku account and app, you will not be able to use the features provided by this tool.
Install
- Install the package globally:
npm i -g herokutoolsEnvironment Variables Documentation
herokutools uses environment variables to manage configurations for different Heroku apps. These environment variables allow you to set default values that the tool will use when no specific options are provided.
Available Environment Variables
HEROKU_TOOL_APP_1: The default Heroku app name used when no options are provided.HEROKU_TOOL_APP_2: The Heroku app name used when -i 2 is specified.HEROKU_TOOL_APP_3: The Heroku app name used when -i 3 is specified.
Setting Environment Variables
You can set these environment variables in your shell configuration file (e.g., .bashrc, .zshrc, .bash_profile, etc.) or directly in your terminal session.
Example: Setting Environment Variables in .bashrc or .zshrc
export HEROKU_TOOL_APP_1=my-default-app
export HEROKU_TOOL_APP_2=my-second-app
export HEROKU_TOOL_APP_3=my-third-appAfter adding these lines, reload your shell configuration:
source ~/.bashrc # or source ~/.zshrcExample: Setting Environment Variables in the Terminal
export HEROKU_TOOL_APP_1=my-default-app
export HEROKU_TOOL_APP_2=my-second-app
export HEROKU_TOOL_APP_3=my-third-appUsing Environment Variables in herokutools
When you run commands with herokutools, it will use the environment variables you have set to determine the default Heroku app names.
Example: Fetching Logs with hl
If you have set HEROKU_TOOL_APP_1 to my-default-app, running the hl command without any options will fetch logs for my-default-app:
hlTo fetch logs for the app set in HEROKU_TOOL_APP_2, use the -i option:
hl -i 2Example: Scaling and Restarting Dynos with hd
To scale the dynos for the default app (stored in HEROKU_TOOL_APP_1) to 2:
hd web 2To restart the dynos for the default app:
hd -rNotes
- Ensure that the environment variables
HEROKU_TOOL_APP_1,HEROKU_TOOL_APP_2, andHEROKU_TOOL_APP_3are set in your environment to use the index options effectively. - The commands use the Heroku CLI internally to manage the apps, so make sure you have the Heroku CLI installed and authenticated.
Commands
hl Command Documentation
The hl command is a CLI wrapper for fetching logs from your Heroku apps. It provides an easy way to view logs for your Heroku applications.
Usage
hl [options]Options
-i, --index [index]: Index of the app to log. Valid values are1,2, or3. If no index is provided, it defaults to the app name stored inprocess.env.HEROKU_TOOL_APP_1.-a, --app [app name]: Logs for your Heroku app. If not provided, it defaults to the saved app name based on the index.
Examples
Default Usage
If no options are passed, the command will fetch logs for the app name stored in process.env.HEROKU_TOOL_APP_1.
hlUsing Index
To fetch logs for the app name stored in process.env.HEROKU_TOOL_APP_2:
hl -i 2Using App Name
To fetch logs for a specific app name:
hl -a my-heroku-appEnvironment Variables
HEROKU_TOOL_APP_1: The default Heroku app name used when no options are provided.HEROKU_TOOL_APP_2: The Heroku app name used when-i 2is specified.HEROKU_TOOL_APP_3: The Heroku app name used when-i 3is specified.
hd Command Documentation
The hd command is a CLI wrapper for scaling and restarting dynos for your Heroku apps. It provides an easy way to manage the number of dynos running for your application and reset them when needed.
Usage
hd [options] [dyno] [quantity]Options
-a, --app [app name]: The Heroku app name. If not provided, it defaults to the saved app name based on the index.-r, --restart: Restart the dynos for the specified app.
Examples
Scale Dynos
To scale the dynos for a specific app to 3:
hd -a my-heroku-app web 3To scale the dynos for the default app (stored in HEROKU_TOOL_APP_1) to 2:
hd web 2Restart Dynos
To restart the dynos for a specific app:
hd -a my-heroku-app -rTo restart the dynos for the default app (stored in HEROKU_TOOL_APP_1):
hd -rEnvironment Variables
HEROKU_TOOL_APP_1: The default Heroku app name used when no options are provided.HEROKU_TOOL_APP_2: The Heroku app name used when -i 2 is specified.HEROKU_TOOL_APP_3: The Heroku app name used when -i 3 is specified.
he Command Documentation
The he command is a CLI wrapper for managing environment variables for your Heroku apps. It provides an easy way to get, set, and remove environment variables.
Usage
he [options] [key] [value]Options
-a, --app [app name]: The Heroku app name. If not provided, it defaults to the saved app name based on the index.-s, --set [key] [value]: Set the value of an environment variable.-r, --remove [key]: Remove an environment variable.
Examples
Get Environment Variable
To get all environment variables for a specific app:
he -a my-heroku-app -gTo get the value of an environment variable for the default app (stored in HEROKU_TOOL_APP_1):
heSet Environment Variable
To set the value of an environment variable for a specific app:
he -a my-heroku-app MY_VAR=my_valueTo set the value of an environment variable for the default app (stored in HEROKU_TOOL_APP_1):
he MY_VAR=my_valueRemove Environment Variable
To remove an environment variable for a specific app:
he -a my-heroku-app -r MY_VARTo remove an environment variable for the default app (stored in HEROKU_TOOL_APP_1):
he -r MY_VARhtr Command Documentation
The he command is a CLI wrapper for transferring a heroku app to a different user.
Usage
he [options] [key] [value]Options
-a, --app [app name]: The Heroku app name. If not provided, it defaults to the saved app name based on the index.-e, --email <email>: Get the value of an environment variable.
Notes
- Ensure that the environment variables
HEROKU_TOOL_APP_1,HEROKU_TOOL_APP_2, andHEROKU_TOOL_APP_3are set in your environment to use the index options effectively. - The command uses the
heroku logs -a <app_name> --tailcommand internally to fetch and display the logs in real-time.
First Stable Version
We are excited to announce that the first stable version of herokutools will be 1.0.0. This release will include all the core features, including fetching logs, scaling and restarting dynos, and setting environment variables for your Heroku apps.
Stay tuned for the release, and thank you for your support and feedback during the beta phase!
For more information, refer to the source code.
Inspiration by: ctsrc and his repotools
Star on GitHub 🤩
If you like this tool please take a moment to star this project on GitHub.
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago