Navigation

Deploy Changes with Stitch CLI

Overview

You can deploy changes to your Stitch app with Stitch CLI by importing an application directory with configuration files that define the updated app.

Prerequisites

Procedure

1

Prepare the Application Directory

Export your application to a local application directory. Alternatively, create a new application directory that contains a stitch.json file with your application’s app_id.

{
  "app_id": "<Your Application ID>"
}
2

Add or Update Application Entities

Add sub-directories and configuration files for any new entities you’re importing, or update the values in existing entity files. All configuration files must conform to the Application File Schema.

3

Authenticate a MongoDB Atlas User

To import or update a MongoDB Stitch application with stitch-cli, users must authenticate with Atlas using an API Key.

stitch-cli login --api-key=my-api-key --private-api-key=my-private-api-key
4

Run the Import Command

Use the stitch-cli import to deploy your changes:

stitch-cli import --strategy=merge

Import Strategy

The --strategy flag indicates how you want Stitch to handle configuration files that are missing or duplicated compared to the currently deployed version of your application. For more information, see import strategies.

If you want to upload static assets to Stitch Hosting, include the static assets in the /hosting/files directory and specify the --include-hosting option:

stitch-cli import --strategy=merge --include-hosting

If you want to upload external dependencies, include your archived node_modules in the /functions directory and specify the --include-dependencies option:

stitch-cli import --strategy=merge --include-dependencies
5

Review and Confirm Import Diff

Before committing the import, stitch-cli will show you a diff of the changes that will be made to your application. Review the diff to ensure that all changes are correct then confirm the import.

After successfully importing your application, Stitch will automatically deploy a new version of your app and update your local application directory to match the new deployment.