Published 2 months ago

Setting Up Your Own Private HarmonyOS Package Server

Software Development
Setting Up Your Own Private HarmonyOS Package Server

Setting Up Your Own Private HarmonyOS Package Server

This guide details setting up a private server for sharing HarmonyOS packages, addressing the need for secure, internal distribution of components and libraries. Unlike public repositories, a private server allows sharing of dynamic shared packages and ensures confidentiality within your organization or team. This comprehensive guide walks you through the process from setup to usage.

I. Installing and Configuring the ohpm-repo Server

1. Node.js Environment

The ohpm-repo server relies on Node.js. If you have DevEco Studio installed, Node.js should already be configured. Otherwise, download and install it from the official Node.js website: https://nodejs.org/download/release/latest/. Verify the installation by running node -v in your terminal.

2. Downloading and Installing ohpm-repo

Download the ohpm-repo package from the Huawei Developer website: https://developer.huawei.com/consumer/cn/download/ (Note: This link might need updating based on availability). Unzip the downloaded file. Add the bin directory's path to your system's PATH environment variable. Verify the installation using ohpm-repo -v.

/uploads/image_103ec7d29c.png

3. IP Address Configuration

For local use, no changes are needed. For network use, modify the listen parameter in config.yaml (located in the conf directory) to use your server's IP address and port. For example: listen: your_server_ip:8088

/uploads/image_30f02dc837.png

4. Additional Configuration Options

The config.yaml file allows configuring various aspects of the server, including the installation root directory (deploy_root) and database storage path (db.config.path).

deploy_root: '' # Installation root directory (defaults to user's home directory)
db:
  type: filedb
  config:
    path: ./db # Local database storage path (defaults to <deploy_root>/db)

5. Installation and Startup

Run ohpm-repo install followed by ohpm-repo start from the bin directory to install and start the server. The server's data will be stored in the deploy_root directory. Access the server's web interface at the configured IP address and port (default: localhost:8088). The initial login credentials are: admin/12345Qq!

/uploads/image_806a3e0424.png

II. Uploading a Static Shared Package

1. Key Configuration

Generate an SSH key pair using ssh-keygen -m PEM -t RSA -b 4096 -f <your_key_path>. This creates a public key (.pub) and a private key. Upload the public key to the ohpm-repo server's authentication management section.

/uploads/image_86b807f5bf.png

Set the private key path using ohpm config set key_path <your_key_path>. Make sure the path to your ohpm executable is added to your system's PATH environment variable (usually found in the DevEco Studio installation directory under tools\ohpm\bin).

/uploads/image_09491f266a.png

Copy your publish ID from your user profile on the ohpm-repo server and set it using ohpm config set publish_id <your_publish_id>

2. Web UI Upload

Navigate to the package management section of the ohpm-repo web interface, click "Upload Package", select your .har file, and upload. Ensure that the organization name matches the one used in your package.

3. ohpm Command-Line Upload

Set the private repository URL using: ohpm config set publish_registry <ohpm-repo_address>/repos/ohpm Then publish your package using ohpm publish demo.har. You will be prompted for your password.

III. Uploading Dynamic Shared Packages

Dynamic shared packages (HSP) require a different approach. They must first be built in release mode (within DevEco Studio) to generate a .tgz package. Once built, utilize the ohpm publish command (with the private registry already configured) to upload the .tgz file.

IV. ohpm-repo Web Interface Overview

The ohpm-repo web interface provides a simple, visual way to manage packages. You can view, search, and manage user accounts, repositories, and authentication settings.

V. Integrating the Private Server into Your Project

Configure your project to use the private server with: ohpm config set registry <ohpm-repo_address>/repos/ohpm You can then install packages from the private server using ohpm install <package_name> or by adding them to your project's oh-package.json5.

VI. Conclusion

Setting up a private ohpm-repo server offers a secure and efficient way to manage your HarmonyOS shared packages. Remember to maintain consistent organization names between your packages and the server, and consider configuring both private and public registry addresses for convenient access to all necessary packages.

Hashtags: #HarmonyOS # PackageServer # ohpm-repo # PrivateRepository # SharedPackages # StaticPackages # DynamicPackages # HSP # DevEcoStudio # SoftwareDevelopment

Related Articles

thumb_nail_Unveiling the Haiku License: A Fair Code Revolution

Software Development

Unveiling the Haiku License: A Fair Code Revolution

Dive into the innovative Haiku License, a game-changer in open-source licensing that balances open access with fair compensation for developers. Learn about its features, challenges, and potential to reshape the software development landscape. Explore now!

Read More
thumb_nail_Leetcode - 1. Two Sum

Software Development

Leetcode - 1. Two Sum

Master LeetCode's Two Sum problem! Learn two efficient JavaScript solutions: the optimal hash map approach and a practical two-pointer technique. Improve your coding skills today!

Read More
thumb_nail_The Future of Digital Credentials in 2025: Trends, Challenges, and Opportunities

Business, Software Development

The Future of Digital Credentials in 2025: Trends, Challenges, and Opportunities

Digital credentials are transforming industries in 2025! Learn about blockchain's role, industry adoption trends, privacy enhancements, and the challenges and opportunities shaping this exciting field. Discover how AI and emerging technologies are revolutionizing identity verification and workforce management. Explore the future of digital credentials today!

Read More
Your Job, Your Community
logo
© All rights reserved 2024