Migrate from Remote Package Repositories
If you host packages in an external repository (source repository), at some point, you may want to move the packages to a repository in Space (target repository). For this purpose, you can use the space
command-line tool.
Supported repository types
Copying an entire repository | Copying specific packages | |
---|---|---|
Cargo (Rust) | ||
Container | ||
Composer | ||
Dart | ||
Maven | ||
NuGet | ||
npm | (only specific scopes) | |
Python Package Index |
1. Get the 'space' command-line tool
The
space
tool is provided as a Docker image.To get the image, run:
docker pull public.registry.jetbrains.space/p/space/containers/space-cli-jvm:latestTo simplify running the tool, you can create an alias (e.g.
space
) for running the image:docker tag public.registry.jetbrains.space/p/space/containers/space-cli-jvm:latest space
2. Get a Space authorization token
To upload packages to a Space Packages repository, the space
tool needs a Space authorization token. The easiest way is to use a personal access token that will allow the tool to act in Space on your behalf.
To create a token, go to My Profile | Authentication | Personal Tokens and choose New personal token.
When creating the token, provide it as minimum permissions as possible:
In Token permissions, select Limited access.
In Add context, choose Project and specify the project your target package repository belongs to.
Add Read package repositories and Write package repositories for giving Read and Write access correspondingly.
Copy the generated permanent token to a secure place. Next in this section, we will refer to this token as
space_auth_token
.
3. Copy packages from the remote repository
Configure the
space
tool.The configuration is stored in the
~/.space/client-config
file and includes the Space access token and the URL of your Space instance. To create the file, run:docker run -v ~/.space:/root/.space space configure https://mycompany.jetbrains.space space_auth_tokenHere we bind the directory on the local machine~/.space
to the directory in the container/root/.space
. This way, the configuration file created in the container will be stored locally and can be further reused.Copy packages from the remote repository. The tool supports the following commands that correspond to the supported repository types:
packages-npm migrate
packages-maven migrate
packages-pypi migrate
For example:
To copy the entire repository:
docker run -v ~/.space:/root/.space space packages-maven migrate \ --target-repo-url https://maven.pkg.jetbrains.space/mycompany/p/projectkey/my-maven-repo \ --source-repo-url https://somemavenrepo.url \ --source-repo-token source_repo_tokenHere
--target-repo-url
specifies the URL of the target Space repository and--source-repo-url
specifies the URL of the source repository.--source-repo-token
specifies the bearer token for authorization in the source repository. Alternatively, you can authorize the tool with--source-repo-login
and--source-repo-password
.Note that Space doesn't support migration of the entire repository for npm. You can copy only the packages belonging to a particular scope. For example, to copy all packages from
@somescope
:docker run -v ~/.space:/root/.space space packages-npm migrate \ --package-scope @somescope \ --target-repo-url https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm \ --source-repo-url https://somerepo.url \ --source-repo-token source_repo_tokenTo copy only the
packageA
andpackageB
from an npm repository:docker run -v ~/.space:/root/.space space packages-npm migrate \ --package-names packageA,packageB \ --target-repo-url https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm \ --source-repo-url https://somerepo.url \ --source-repo-token source_repo_tokenTo get help on all possible migration options, use
--help
. For example:docker run space packages-npm migrate --help
- Provide configuration as a file
You can specify migration configuration in a text file and provide the path to the file as an argument, e.g.
--config-file /root/.space/config.txt
. Here/root/.space/config.txt
is the path inside the Docker container.The contents of this file may look as follows:
packageNames=packageA,packageB sourceRepoUrl=https://somerepo.url targetRepoUrl=https://npm.pkg.jetbrains.space/mycompany/p/projectkey/mynpm latestOnly=false