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.
- 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.
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 the package globally:
npm i -g herokutools
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-app
After adding these lines, reload your shell configuration:
source ~/.bashrc # or source ~/.zshrc
Example: 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-app
Using 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
:
hl
To fetch logs for the app set in HEROKU_TOOL_APP_2
, use the -i
option:
hl -i 2
Example: Scaling and Restarting Dynos with hd
To scale the dynos for the default app (stored in HEROKU_TOOL_APP_1
) to 2:
hd web 2
To restart the dynos for the default app:
hd -r
Notes
- Ensure that the environment variables
HEROKU_TOOL_APP_1
,HEROKU_TOOL_APP_2
, andHEROKU_TOOL_APP_3
are 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.
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.
hl [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.
If no options are passed, the command will fetch logs for the app name stored in process.env.HEROKU_TOOL_APP_1
.
hl
To fetch logs for the app name stored in process.env.HEROKU_TOOL_APP_2
:
hl -i 2
To fetch logs for a specific app name:
hl -a my-heroku-app
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.
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.
hd [options] [dyno] [quantity]
-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.
To scale the dynos for a specific app to 3:
hd -a my-heroku-app web 3
To scale the dynos for the default app (stored in HEROKU_TOOL_APP_1
) to 2:
hd web 2
To restart the dynos for a specific app:
hd -a my-heroku-app -r
To restart the dynos for the default app (stored in HEROKU_TOOL_APP_1
):
hd -r
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.
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.
he [options] [key] [value]
-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.
To get all environment variables for a specific app:
he -a my-heroku-app -g
To get the value of an environment variable for the default app (stored in HEROKU_TOOL_APP_1):
he
To set the value of an environment variable for a specific app:
he -a my-heroku-app MY_VAR=my_value
To set the value of an environment variable for the default app (stored in HEROKU_TOOL_APP_1):
he MY_VAR=my_value
To remove an environment variable for a specific app:
he -a my-heroku-app -r MY_VAR
To remove an environment variable for the default app (stored in HEROKU_TOOL_APP_1):
he -r MY_VAR
The he
command is a CLI wrapper for transferring a heroku app to a different user.
he [options] [key] [value]
-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.
- Ensure that the environment variables
HEROKU_TOOL_APP_1
,HEROKU_TOOL_APP_2
, andHEROKU_TOOL_APP_3
are set in your environment to use the index options effectively. - The command uses the
heroku logs -a <app_name> --tail
command internally to fetch and display the logs in real-time.
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
If you like this tool please take a moment to star this project on GitHub.