DEV Community

ZHZL-m
ZHZL-m

Posted on

【Journey of HarmonyOS Next】DevEco Studio User Guide (4)

Image description

1 -> Adapt to OHPM package management

OHPM CLI (OpenHarmony Package Manager Command-line Interface) is a package management tool for the HarmonyOS ecosystem that supports the release, installation, and dependency management of shared packages.

If you create a new project with API 9 or later on DevEco Studio 3.1 Release or later, you will use ohpm as the default package manager.

illustrate

API 8/9 historical projects that only use the npm package management need to be migrated.

The overall migration process is as follows:

  1. Migration configuration file: Migrate the npm package management related configuration file package.json or .npmrc under the project and module to the oh-package.json5 or .ohpmrc file.

illustrate

If there is no .npmrc file in the original project, you do not need to migrate the .npmrc file to the .ohpmrc file.

  1. Add compilation and build related files: Add hvigor related wrapper files to the project, including hvigorw, hvigorw.bat, hvigor-config.json5, and hvigor-wrapper.js configuration files.

  2. Delete npm package management files that are no longer in use: including package.json, package-lock.json, .npmrc, and node_modules, which need to be deleted at the project and module levels.

1.1 -> Manual migration of historical projects

Before migration, you need to back up the project.

The migration process is as follows:

  1. At the project/module level, at the configuration file involving package.json or .npmrc, create an oh-package.json5 or .ohpmrc file at the same directory level.

illustrate

If the historical project is a C++ project, src>main> the cpp directory contains package.json or .npmrc, and the same process is required.

  1. Copy the fields to be migrated in the historical project package.json and .npmrc files to the corresponding oh-package.json5 and .ohpmrc files.

illustrate

The dependencies field of the package.json file of the project is handled as follows:
@ohos/hypium: test the dependencies of the framework, which needs to be placed in the devDependencies field of the oh-package.json5 file during migration.
Remove @ohos/hvigor and @ohos/hvigor-ohos-plugin fields without migrating to oh-package.json5;
Other dependencies can be copied directly to the dependencies field in oh-package.json5.
Except for the fields presented in the table, the remaining fields in the package.json cannot be migrated. If you use the remaining fields in the historical project, please give feedback on the fields you use (select the Chinese version and click "Feedback").

  1. The project needs to add ohpm to compile and build a four-piece set of hvigorw, hvigorw.bat, hvigor-config.json5, and hvigor-wrapper.js. You can create a new project with API 9, copy the hvigorw, hvigorw.bat, hvigor-config.json5, and hvigor-wrapper.js configuration files in the new project, and paste them into the corresponding location in the historical project folder.

  2. Delete the package.json, package-lock.json, . npmrc and node_modules.

Image description

  1. Click File>Sync and Refresh Project, and the manual migration of the historical project is completed.

Image description

2 -> Turn off data acquisition

When DevEco Studio is started for the first time, a pop-up window prompts you to enable data collection. This function is used to help DevEco Studio improve the user experience, and the collected data will be processed in accordance with the HUAWEI DevEco Studio Platform and Privacy Statement.

Image description

If you need to disable the data collection function in the future, go to File > Settings (DevEco Studio > Preferences for macOS) > Appearance & Behavior > System Settings > Data Sharing Settings page. Uncheck Send usage statistics to disable data collection.

Image description

3 -> Log upload

If DevEco Studio is stuck, stuck, or otherwise faulty during development, you can click Send Report in the IDE Error pop-up window, click OK, and send log information back to DevEco Studio.

Image description

You can also use the menu bar Help > Collect Logs and Diagnostic Data to select and upload relevant logs to help DevEco Studio improve the stability experience.

Image description

If you need to disable the data collection function in the future, go to File > Settings (DevEco Studio > Preferences for macOS) > Appearance & Behavior > System Settings > Data Sharing Settings page. Uncheck Send usage statistics to disable data collection.

Image description

Top comments (0)