One useful tool in the CLI is the ability to export a project from an instance of Kodexa and import it into a different organization in the same instance or another instance.
You can do this using the CLI commands, for example to export a project you would use:
Usage: kodexa export-project [OPTIONS] PROJECT_ID Options: --url TEXT The URL to the Kodexa server --token TEXT Access token --output TEXT The path to export to --help Show this message and exit.
You can simply project the ID of the project that you wish to export.
You can find the project ID by looking up the project using the standard resource methods in the CLI, for example if we want to list all the projects matching a certain name we can use:
$ kodexa get projects --query web Listing projects ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ id ┃ organization.name ┃ name ┃ description ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ 8a8a83f380d207d00180d2bf00000b3b │ Testing │ WEB 3 │ Test WEB and S3 together │ │ 8a8a835b805feb9e01805ff5571900e8 │ Demo 5.0 │ Web Scripting Example │ Using full scripting to interact with websites │ │ 8a8a833c805ca6df01805fd521ce0561 │ Demo 5.0 │ Web Crawl to Storage Publishing │ A project for extracting data from automated PDF downloads through S3 publishing │ └──────────────────────────────────┴───────────────────┴─────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────┘ 3 projects found, page 1 of 1
The first column contains the ID of the project and therefore if you wanted to export the WEB 3 testing project to a folder in /tmp/export you can use the command:
$ kodexa export-project 8a8a83f380d207d00180d2bf00000b3b --output /tmp/export
This will create a folder with the name of the Project under /tmp/export. For example if you project was called “My Project” you will end up with a folder call /tmp/export/My Project.
You can now import this into another organization as identified by its slug. It will create the project with the same name, and the components (i.e. stores, etc.) will also have the same names in this organization.
To do this you simply run:
$ kodexa import-project <insert-new-org-slug> "/tmp/export/My Project"
It returns the following status updates
Importing project from /tmp/export/My Project Organization: new-org-slug
If successful, the following line shows up:
You can now access that project in the new organization and environment you have specified.