# Migrating E2B SDK from v0.* to v1.0 using Grit

This guide explains how to migrate your project from **E2B SDK `v0.*`** to **E2B SDK `v1.0`** using [Grit](https://www.grit.io/) and our custom migrations.
This mostly automates the process of searching through your codebase to update code to migrate to the new SDK without errors. However, this is not a 100% accurate process, and you should expect human intervention to be required.

## Step 1: Install the Grit CLI

You can install **Grit CLI** using one of the following methods:

### Option 1: Install via NPM

```bash
npm install --location=global @getgrit/cli
```

### Option 2: Install via bash script

```bash
curl -fsSL https://docs.grit.io/install | bash
```

## Step 2: Prepare for migration

Before applying the migration, format your code and commit your changes to ensure you have a stable state to revert to if necessary.

```bash
git add .
git commit -m "Last changes made"
```

## Step 3: Run Grit with the Custom Pattern

To apply the custom migration pattern, run the following command for your project. The `--interactive` flag allows you to review each change as it is made.

### For JavaScript/TypeScript:

```bash
grit apply github.com/e2b-dev/e2b-cookbook#e2b_v0_to_v1_js --interactive
```

### For Python:

```bash
grit apply github.com/e2b-dev/e2b-cookbook#e2b_v0_to_v1_py --interactive
```

## Step 5: Review changes

Once the migration is applied, review the changes for possible mistakes, including code that was broken (false positives) or outdated code that was not fixed (false negatives) by the migration. Such issues you may encounter include:

- ⚠️ If non-E2B objects with `.close()` methods, `.id` attributes, etc. exist in files that import E2B libraries, they will be incorrectly changed. You need to reject these changes manually.
- ⚠️ The output structure of `Sandbox.list()` has changed in the new SDK. You must manually rewrite your code to account for this.
- ⚠️ The global `cwd` option no longer exists when creating a Sandbox. You must manually rewrite your code to include the `cwd` option with each command.

You should manually review all changes made by Grit to fix these "gotchas" and others which are sure to exist.

## Step 6: Commit changes

Before commiting the changes made by Grit, it's recommended to re-format the generated code following the convention of your choice. After verifying the changes and reformatting code, commit them to Git.

```bash
git add .
git commit -m "Migrate project to E2B SDK v1.0"
```

## Step 7: Test your application

Now, thoroughly test your application to make sure the migration is successful and everything is functioning as expected.

---

By following these steps, you can easily migrate your TypeScript or Python project from **E2B SDK `v0.*`** to **E2B SDK `v1.0`** using Grit. Don’t forget to use version control to track all changes throughout the process and to thoroughly test your application after migrating.
