This topic describes how to migrate artifacts from third-party NPM repositories to private NPM repositories in Alibaba Cloud DevOps Packages.
Procedure
Alibaba Cloud DevOps supports two methods to migrate artifacts from third-party NPM repositories to private NPM repositories in Packages. You can choose a migration method based on the type of your artifact source:
Import artifacts from Nexus3.
Import artifacts from other NPM artifact sources.
Step 1: Download the migration tool
Download URL: https://agent-install-beijing.oss-cn-beijing.aliyuncs.com/artifact-migration-0.0.2-jar-with-dependencies.jar
Download the JAR file from the preceding URL to your local computer and save it as artifact-migration-jar-with-dependencies.jar.
Step 2: Run the migration tool
Import artifacts from Nexus3
Make sure that Java 8 or later is installed on your computer. Run the following command in the directory where the JAR file is located to view the help information: java -jar artifact-migration-jar-with-dependencies.jar migrateNexusNpm --help.
java -jar artifact-migration-jar-with-dependencies.jar migrateNexusNpm --help
Usage: migrate migrateNexusNpm [-hV] [--dryrun] [--exclude=<exclude>]
[--include=<include>] --nexus-host=<nexusHost>
--source-repo-id=<repoId>
--source-repo-password=<repoPassword>
--source-repo-username=<repoUsername>
--target-repo-password=<repoPassword>
--target-repo-url=<repoUrl>
--target-repo-username=<repoUsername>
Migrate NPM artifacts from Nexus3
--dryrun Dry run. Artifacts will not be actually uploaded.
--exclude=<exclude> The names of the artifacts to exclude. Separate multiple names with commas. Fuzzy match is supported.
-h, --help Show this help message and exit.
--include=<include> The names of the artifacts to include. Separate multiple names with commas. Fuzzy match is supported.
--nexus-host=<nexusHost>
The Nexus server address.
--source-repo-id=<repoId>
The source repository ID.
--source-repo-password=<repoPassword>
The password for accessing the source repository.
--source-repo-username=<repoUsername>
The username for accessing the source repository.
--target-repo-password=<repoPassword>
The password for accessing the destination repository. You can view the password in the repository User Guide in the Packages console.
--target-repo-url=<repoUrl>
The destination repository URL, which can be found in the repository User Guide in the Packages console.
--target-repo-username=<repoUsername>
The username for accessing the repository repository. You can view the username in the repository User Guide in the Packages console.
-V, --version Print version information and exit.If Chinese characters appear as garbled text in the help information, execute chcp 65001 in the command line before you run the java command.
Example command:
java -jar artifact-migration-jar-with-dependencies.jar migrateNexusNpm --source-repo-id="my-npm-repo" --source-repo-username="admin" --source-repo-password="****" --nexus-host="http://localhost:8081" --target-repo-url="https://packages.aliyun.com/66b3075ffaba0e0aab301c38/npm/repo-yhqkr/" --target-repo-username="66b3****" --target-repo-password="****" --include="@taobao"This command will upload all artifacts with names containing @taobao from the specified Nexus repository my-npm-repo to a repository in Packages. For specific parameter information, go to the Packages homepage, click the destination repository, and view the Import From Nexus3 section in the User Guide.

Import artifacts from other NPM artifact sources
Make sure that Java 8 or later is installed on your computer. Run the following command in the directory where the JAR file is located to view the help information: java -jar artifact-migration-jar-with-dependencies.jar migrateNpm --help.
java -jar artifact-migration-jar-with-dependencies.jar migrateNpm --help
Usage: migrate migrateNpm [-hV] [--dryrun] --package-list=<packageList>
--source-repo-password=<sourceRepoPassword>
--source-repo-url=<sourceRepoUrl>
--source-repo-username=<sourceRepoUsername>
--target-repo-password=<repoPassword>
--target-repo-url=<repoUrl>
--target-repo-username=<repoUsername>
Migrate artifacts from an NPM source to Packages. You need to specify the names of artifacts to migrate.
--dryrun Dry run. Artifacts will not be actually uploaded.
-h, --help Show this help message and exit.
--package-list=<packageList>
Names of artifacts to migrate. Separate multiple names with commas.
--source-repo-password=<sourceRepoPassword>
The password for accessing the source repository.
--source-repo-url=<sourceRepoUrl>
The URL of the source repository.
--source-repo-username=<sourceRepoUsername>
The username for accessing the source repository.
--target-repo-password=<repoPassword>
The password for accessing the destination repository. You can view the password in the repository User Guide in the Packages console.
--target-repo-url=<repoUrl>
The destination repository URL, which can be found in the repository User Guide in the Packages console.
--target-repo-username=<repoUsername>
The username for accessing the destination repository. You can view the username in the repository User Guide in the Packages console.
-V, --version Print version information and exit.If Chinese characters appear as garbled text in the help information, execute chcp 65001 in the command line before you run the java command.
Example command:
java -jar artifact-migration-jar-with-dependencies.jar migrateNpm --source-repo-url="http://127.0.0.1:8081/repository/mynpm" --source-repo-username="admin" --source-repo-password="****" --target-repo-url="https://packages.aliyun.com/66b3075ffaba0e0aab301c38/npm/repo-yhqkr/" --target-repo-username="66b3****" --target-repo-password="****" --package-list=my-package,@bowen/expressjs-hello"This command will migrate all versions of artifacts named @bowen/expressjs-hello and my-package from the repository at http://127.0.0.1:8081/repository/mynpm to a repository in Packages. For specific parameter information, go to the Packages homepage, click the destination repository, and view the Import from other npm source section in the User Guide.

Step 3: View the migration result
When the text migration is finished appears, it indicates that the migration is complete. You can then view the migrated artifacts in the destination repository in Packages:

