目录

ASCF Toolkit (CLI Tool)

ASCF provides a command line tool to control the debugging, conversion, and compilation functions.

Installing the Command Line Tool

To install the command line tool, run the following command:

npm install @atomicservice/ascf-toolkit -g

To obtain the help information, run the following command:

ascf -h

Converting Mini Program Code into ASCF Projects

To obtain the help information for the ASCF tool's conversion behavior, run the following command:

ascf convert -h

To convert your mini program, run the following command, specifying the input (-i) and output (-o) directories. After the conversion, follow Development Guide to ensure compatibility with platform functionalities and to meet the relevant specifications.

ascf convert -i .\path\to\miniprogram -o .path\to\atomicservice-project

Compiling ASCF Source Code

To obtain the help information for the ASCF tool's compilation behavior, run the following command:

ascf compile -h

The following is an example of the compilation command:

ascf compile .\path\to\atomicservice-project

Enabling Hot Reload

Run the following command to enable the hot reload feature:

ascf compile .\path\to\atomicservice-project --serve

Before using hot reload, ensure that Waive restrictions for services under development has been enabled on the device (you can enable it in Developer options).

Creating an Atomic Service Template Project

To obtain the help information for the ASCF tool's behavior of creating an atomic service template project, run the following command:

ascf generate -h

The following is an example command for creating an atomic service template project:

ascf generate .\path\to\atomicservice-project

Command Options

[h2]Global Parameters

Parameter Default Value Description
-h - Obtains the help information.
-c - Clears the conversion output directory.
--logging=[level] debug, info (default), warn, and error Sets the minimum log level.

[h2]convert Command

Parameter Description
convert Performs conversion.
--notaddtodo Ensures no TODO comments are added to the converted source code for unsupported APIs, to reduce source code pollution.

[h2]compile Command

Parameter Default Value Description
compile - Performs compilation.
-m - Enables debug compilation.
-p - Displays the current compilation progress.
--swc - Uses the speedy web compiler (SWC) to compile JavaScript code to improve the compilation efficiency.
--devtool=[type] eval-cheap-source-map Customizes the source map generation behavior.
--templateHoist -

Hoists templates to the page scope to eliminate redundant compilation code and reduce bundle size.

This parameter is required for atomic services converted using the Taro framework.

--skipApiValidator - Skips the support verification of APIs and components to improve the compilation performance.
--serve -

Enables hot reload.

Dependency:

The ASCF runtime version must be 1.0.10 or later.

The ASCF Toolkit version must be 1.0.4 or later.

NOTE

You are advised to use the SWC for compilation when enabling hot reload to improve its efficiency.

--disableSubpackages -

Merges the subpackages into the main package during debug builds to improve build performance.

Dependency:

The ASCF Toolkit version must be 1.0.4 or later.

NOTE

You can set this parameter to false to disable this feature. In this case, subpackages will not be merged into the main package during debug builds.

-ct

--connectorType

hdc (default) and adb Sets the type of the device debugging connector. The value must be adb to enable hot reload on devices running HarmonyOS 4 or earlier.

[h2]build Command

Subcommand Parameter Default Value Description
installDeps -r, --projectRoot Project root directory Installs all dependencies in the oh-package.json5 file.
clean -r, --projectRoot Project root directory Cleans ohpm installation artifacts and the build directory containing project build artifacts.
assembleHap

-r, --projectRoot

-m, --buildMode

-r: default project root directory

-m: debug (default) and release

Builds HAP and HSP packages.
assembleApp

-r, --projectRoot

-m, --buildMode

-r: default project root directory

-m: debug (default) and release

Builds the .app package.
assembleAndInstallHap

-r, --projectRoot

-m, --buildMode

-r: default project root directory

-m: debug (default) and release

Builds HAP and HSP packages and automatically installs and starts them.
installHap -r, --projectRoot Project root directory Installs the HAP and HSP packages that have been built for the project.
uninstall -r, --projectRoot Project root directory Uninstalls the atomic service specified by bundleName.
start -r, --projectRoot Project root directory Launches the atomic service specified by bundleName.

[h2]generate Command for Creating an Atomic Service Template Project

Parameter Supported Value Description
generate - Command for creating an atomic service template project.
--tid HelloASCF, ASCFDemos Template ID.
--appId - App ID of the atomic service.
--appName - Atomic service name.
--appDesc - Atomic service description.
--appNameEn - Atomic service name in English.
--appDescEn - Atomic service description in English.
--deviceTypes phone, tablet, phone, tablet Device type.

Using npm Packages

  1. Install npm packages.

    Run the following command in the ascf_src directory where package.json is stored to install npm packages:

    npm install
  2. Build npm dependencies.

    Run the following command to build npm dependencies:

    ascf buildNpm <projectRoot>

    If you use DevEco Studio to develop an ASCF project, run the following command to build npm dependencies:

    hvigorw buildNpm