This content originally appeared on DEV Community and was authored by 程序员一鸣
Foreword
this article is based on DevEco Studio 5.0.5 Release
there may be a question as soon as the old iron comes up, hvigorw, what is this? It seems useless, Ah, don’t say that, hvigorw, but accompany you all the time, without it, it can be said that Hongmeng development will end immediately, which is so important.
First of all, let’s make a confusing interpretation. hvigorw is used as the wrapper packaging tool of Hvigor, its main function is to support the automatic installation of the Hvigor build tool and related plug-in dependencies, as well as the execution of Hvigor build commands. It’s not the same thing as hvigorfile.ts and hvigor-config.json5 in our project, so don’t confuse it.
The hvigorfile.ts file, in our root project, is an application-level or Module-level compile build task script that allows developers to customize the build tool version and configuration parameters that control build behavior.
The hvigor-config.json5 file is in the hvigor directory in the project:
its main function is to specify the version number of the development state build tool of the current project, the dependency version of the build task and script, etc.; Specify the relevant capabilities of the build tool, including log level, execution strategy, etc.; Specify the relevant configuration parameters of the built runtime node, as well as other additional parameters passed to the build script, etc.
One is for compilation and construction, and the other is for configuration construction, so we should pay attention to identify the difference.
Some old iron said, where is hvigorw used, why haven’t I seen it?
hvigorw is much more useful. Have we ever thought about how the code runs to the simulator or mobile phone when you click the run button? Yes, through hvigorw.
When we click on run, we can see in the Build option in the bottom console that hvigorw performs the task.
When we click on Clean Project in the navigation bar:
found, or hvigorw is helping us execute the cleanup project.
It can be found that hvigorw is almost everywhere, and its role is even more important and irreplaceable in the following assembly line packaging.
hvigorw environment configuration
there are currently two ways to use hvigorw, one is to use the DevEcoStudio sdk, and the second is to download a series of Tools used in the development of HarmonyOS applications, Command Line Tools, both of which can be used at present.
DevEcoStudio comes with hvigorw
if you use DevEcoStudio’s own need to be used together with node, open a Hongmeng project, open the terminal at the bottom, use node, and then add the hvigorw.js path. For example, I want to query the current hvigorw version, which can be obtained as follows, and the version of hvigorw can be displayed correctly, which proves to be correct.
Some students may say, where is the path of hvigorw.js? It is in the tools Directory installed by your DevEcoStudio, and you can also obtain it in this way. When you execute the running project or clear the project cache, is there a record of executing commands in Build? In the first line, you can view the path of hvigorw.js. In fact, we can see that the system is also executed in this way.
It should be noted that if your node is configured with environment variables, you can directly use node. If not, please follow the execution of the system in the above figure and add the full path.
The above is the command execution of my Mac computer. If you are a windows system, you need to add double quotation marks to the path of hvigorw.js.
Use Command Line Tools
Command Line Tools, which is a collection of HarmonyOS application development Tools used in a series of Tools, including many practical Tools, such as SDK management sdkmgr, code check codelinter, three-party library package management ohpm, Command Line analysis hstack, to use it need to go to the official website to download separately:
the download address is as follows:
https://developer.huawei.com/consumer/cn/download/command-line-tools-for-hmos
select the corresponding system version to download.
After downloading, the next step is environment configuration. If you are a windows system, add hvigorw’s PATH ${COMMANDLINE_TOOL_DIR}/command-line-tools/bin to the system or user’s PATH variable, where COMMANDLINE_TOOL_DIR is the installation PATH of the command line tool; Mac, open the terminal tool and execute the following command:
export PATH=${COMMANDLINE_TOOL_DIR}/command-line-tools/bin:$PATH
after the environment is configured, switch to the project root directory and run the following command. If you can query the Hvigor version information, confirm that the installation is successful.
hvigorw -v
Related Summary
originally, I was going to continue to introduce the relevant commands of hvigorw, but the length is a bit too long. Let’s put it into the next article to summarize it. The most important thing in this article is to learn the simple use of hvigorw and be able to correctly display and publish this number. As for both usages, they can be used, mainly depending on your own needs.
This article label: Hongmeng Development Tools/DevEco Studio
This content originally appeared on DEV Community and was authored by 程序员一鸣