Metadata-Version: 2.4
Name: npmove
Version: 0.0.1
Summary: Small CLI to move, back up, and diff n8n workflows between instances.
Author-email: cletusxjq <cletusxjq-hawes@gmx.com>
License: MIT
Project-URL: Homepage, https://github.com/cletusxjq/npmove
Project-URL: Issues, https://github.com/cletusxjq/npmove/issues
Keywords: n8n,workflow,automation,cli,backup,migration
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25
Requires-Dist: click>=8.0
Dynamic: license-file

# npmove

Small command-line tool to move, back up, and diff [n8n](https://n8n.io) workflows between instances.

`npmove` talks to the n8n REST API. It is useful when you have more than one n8n instance (typical setup: dev / staging / prod) and you want to keep workflows in sync without clicking through the UI or hand-editing exported JSON.

## Install

```
pip install npmove
```

Python 3.9+ required.

## Quick start

Save credentials for an instance (do this once per server):

```
npmove auth dev   https://dev.n8n.example.com  --token <api-token>
npmove auth prod  https://n8n.example.com      --token <api-token> --default
```

List workflows on the default instance:

```
npmove list
npmove list --active
```

Export a single workflow to stdout:

```
npmove export 42
```

Export a single workflow to a file:

```
npmove export 42 -o workflows/my-flow.json
```

Export every workflow to a directory (one JSON per workflow, named `<slug>.<id>.json`):

```
npmove export --all -o ./backups/
```

Import a workflow onto another instance:

```
npmove import workflows/my-flow.json --instance prod
```

Optionally rename on import:

```
npmove import workflows/my-flow.json --instance prod --name "My Flow (prod)"
```

Compare a local file with the remote version (auto-match by workflow name, or pass `--id`):

```
npmove diff workflows/my-flow.json --instance prod
```

`diff` exits with status `1` if there are differences — handy for CI checks.

## Commands

| Command | Purpose |
|---|---|
| `npmove auth <name> <url> --token <token>` | Save instance credentials |
| `npmove instances` | List configured instances |
| `npmove forget <name>` | Remove an instance |
| `npmove list` | List workflows on the configured instance |
| `npmove export <id>` | Export one workflow |
| `npmove export --all -o <dir>` | Export every workflow |
| `npmove import <file>` | Create a new workflow on the instance |
| `npmove diff <file>` | Compare local file with the remote workflow |

Run `npmove <command> --help` to see all flags.

## Where credentials are stored

Default location: `~/.npmove/config.json` (the file is chmod-600 on POSIX).
You can override the directory with the `NPMOVE_HOME` environment variable.

The file holds plain text tokens — treat it like any other dotfile that contains secrets.

## What `npmove import` does (and does not)

It creates a **new** workflow on the target instance. It does **not** overwrite an existing one by name or id. If you need to overwrite, delete the target workflow first (`DELETE` in the n8n UI or via the API), then import.

Server-managed fields (`id`, `versionId`, `createdAt`, `updatedAt`, `meta.instanceId`, ...) are stripped before the create call — n8n assigns them.

## Limitations

- Credentials inside workflows are **not transferred** — n8n does not expose secrets via the workflow API, by design. After import, re-link credentials in the n8n UI.
- The tool currently supports the standard self-hosted n8n REST API (`/api/v1/...`). n8n Cloud uses the same shape, set the `--url` accordingly.

## License

MIT
