Introducing glitcheroo: The simple deployment tool for Glitch
Tags: showdev, javascript, git, devops
Published: 2020-05-04 21:07:31

[Glitch](https://glitch.com/) is a free and simple online platform for creating Node.js-based web apps. The friendly, creative Glitch community has shared millions of projects publicly that you can use, view the source code for, and even remix into your own apps. I think Glitch is the best thing to happen to coding in a long time. If you haven't checked it out yet, you should!

[`glitcheroo`](https://www.npmjs.com/package/glitcheroo) is a new command-line tool that enables you to easily deploy a Node.js app to an _existing_ Glitch project, replacing its previous contents. The app you are deploying could be hosted in another Glitch project, or stored in a Git repository on your local device.

Let's review the two primary workflows supported by `glitcheroo`.

## Workflow 1: Remix on Glitch, deploy to Glitch

The Glitch-based workflow is most useful when you have an app that you've developed and shared with other people but want to continue to edit on Glitch. Depending on the circumstances, your app could end up being unavailable to your users for a period of time while you are editing it. Or even worse, your app might be available but in an inconsistent state, which (in the most extreme cases) could lead to data-loss for some users. Not good.

This is where `glitcheroo` comes to the rescue. Instead of editing the app's project directly, first you remix project on Glitch, then you make your changes in the new project, and finally you deploy them back to the original project with `glitcheroo`. You deploy the changes by running the following command in the terminal of the new project:

```sh
npx glitcheroo deploy
```

The first time you run this command you will be asked to provide the Git URL of the original project. (See below for how to find it.) The URL will be saved as a Git remote tracked repository and automatically re-used on subsequent deploys.

(Note: The original project must be configured to receive deployments. See below.)

After this command completes Glitch will automatically detect the project change, reinstall the dependencies, and start the deployed app. Your users won't notice a thing!

## Workflow 2: Remix locally, deploy to Glitch

The local-device-based workflow is useful if you prefer to edit your app offline. This might be because you can't access the Internet for a period of time, or simply because you prefer to use a local editor instead of the online Glitch editor. In this case the workflow is to remix the Glitch project to your local device, make changes in the local project, and then deploy them back to Glitch.

To make this easier, `glitcheroo` includes a `remix` command. You can remix a Glitch project to your local device by running the following command in the terminal of your local device:

```sh
npx glitcheroo remix
```

You will be asked to provide the Git URL of the project you want to remix. (See below for how to find it.) The URL will be saved in a Git as a remote tracked repository and automatically re-used when you deploy the project. You can run the following command to deploy the local app back to the original project:

```sh
npx glitcheroo deploy
```

(Note: The original project must be configured to receive deployments. See below.)

After this command completes Glitch will automatically detect the project change, reinstall the dependencies, and start the deployed app.

## Pre-requisite: configure the target to receive deployments

Before you can deploy to a target project you must first configure it to receive deployments. You can run the following command in the terminal of the Glitch project you want to _target_:

```sh
npx glitcheroo setup-target
```

This only needs to be done once per _target_ project.

**WARNING:** This command allows the Glitch project to be completely overwritten via remote Git operations.

## How to find the Git URL of the target

Both workflows require you to provide the target project's Git URL. This URL contains an API secret and must be kept safe from prying eyes. You can find a project's Git URL in its online Glitch editor, in the "Tools > Import and Export" panel.

## Conclusion

I am the author of the `glitcheroo` tool. I'd love to hear your feedback about it. The [project](https://github.com/bacongravy/glitcheroo) is hosted on [GitHub](https://github.com), and new [issues](https://github.com/bacongravy/glitcheroo/issues) and [pull requests](https://github.com/bacongravy/glitcheroo/pulls) are always welcome.

This project was inspired by [Melissa McEwen's](http://www.melissamcewen.com/) fascinating article [Automating My Deploys From GitHub to Glitch](https://dev.to/glitch/automating-my-deploys-from-github-to-glitch-2fpd), published on [DEV](https://dev.to/) on April 21, 2020.

Huge thanks to Glitch for providing a great service. This project is not affiliated with Glitch in any way.