How to use the command 'ern' (with examples)

How to use the command 'ern' (with examples)

The ’ern’ command is the command-line client for the Electrode Native platform. It provides various functionalities for creating and managing Electrode Native applications, containers, and versions. This article will illustrate different use cases of the ’ern’ command.

Use case 1: Create a new ern application (MiniApp)

Code:

ern create-miniapp application_name

Motivation: This command is used to create a new Electrode Native MiniApp, which is a self-contained JavaScript module that can be included in an Electrode Native container or run directly using the ern run-ios|android command. This is useful when developing individual modules that can be easily integrated into larger Electrode Native projects.

Explanation:

  • application_name: The name of the new application/MiniApp to be created.

Example Output:

Success: MiniApp created at /path/to/application_name

Use case 2: Run one or more MiniApps in the iOS/Android Runner application

Code:

ern run-ios|android

Motivation: This command is used to launch the iOS or Android Runner application with one or more MiniApps running inside it. It allows developers to quickly test and see the behavior of their MiniApps on the target platform without having to go through the entire build and packaging process.

Explanation:

  • run-ios|android: Option to specify whether to run the MiniApps in the iOS or Android Runner application.

Example Output:

Success: iOS/Android Runner launched with MiniApps running inside it.

Use case 3: Create an Electrode Native container

Code:

ern create-container --miniapps /path/to/miniapp_directory --platform ios|android

Motivation: This command is used to create an Electrode Native container, which is a package containing one or more MiniApps. Containers provide a convenient way to bundle, distribute, and run MiniApps within the Electrode Native platform.

Explanation:

  • --miniapps: Path to the directory containing the MiniApps to be included in the container.
  • --platform: Option to specify the target platform for the container (iOS or Android).

Example Output:

Success: Electrode Native container created at /path/to/container_directory.

Use case 4: Publish an Electrode Native container to a local Maven repository

Code:

ern publish-container --publisher maven --platform android --extra '{"groupId":"com.walmart.ern","artifactId":"quickstart"}'

Motivation: This command is used to publish an Electrode Native container to a local Maven repository. Publishing containers to a Maven repository allows for easier distribution and sharing of containers across projects and teams.

Explanation:

  • --publisher maven: Option to specify the publisher to be used for publishing the container.
  • --platform android: Option to specify the target platform for the container (Android).
  • --extra '{"groupId":"com.walmart.ern","artifactId":"quickstart"}': Additional arguments in JSON format containing the Maven groupId and artifactId for the container.

Example Output:

Success: Electrode Native container published to Maven repository with the groupId 'com.walmart.ern' and artifactId 'quickstart'.

Use case 5: Transform an iOS container into a pre-compiled binary framework

Code:

ern transform-container --platform ios --transformer xcframework

Motivation: This command is used to transform an existing iOS container into a pre-compiled binary framework using the ‘xcframework’ transformer. This can be useful for optimizing and improving the performance of iOS containers.

Explanation:

  • --platform ios: Option to specify the target platform for the container (iOS).
  • --transformer xcframework: Option to specify the transformer to be used for the transformation, in this case, ‘xcframework’.

Example Output:

Success: iOS container transformed into a pre-compiled binary framework using the 'xcframework' transformer.

Use case 6: List all installed versions of Electrode Native

Code:

ern platform versions

Motivation: This command is used to list all the installed versions of the Electrode Native platform. It can be helpful when managing and maintaining multiple versions of Electrode Native across different projects.

Explanation: None

Example Output:

Installed Versions:
- 2.0.0
- 2.1.0
- 2.1.1

Use case 7: Set a logging level

Code:

ern platform config set logLevel trace|debug

Motivation: This command is used to set the logging level for the Electrode Native platform. Setting the appropriate logging level can help in debugging and troubleshooting issues in the platform.

Explanation:

  • logLevel trace|debug: Option to specify the desired logging level, either ’trace’ or ‘debug’.

Example Output:

Success: Logging level set to 'debug'.

Conclusion:

The ’ern’ command provides a comprehensive set of functionalities for creating, managing, and publishing Electrode Native applications, containers, and versions. By understanding and utilizing these different use cases, developers can effectively leverage the power and flexibility of the Electrode Native platform.

Related Posts

Using PlatformIO Command "pio check" (with examples)

Using PlatformIO Command "pio check" (with examples)

Introduction PlatformIO is an open-source ecosystem for IoT development with cross-platform build systems, library managers, and frameworks.

Read More
How to use the command 'cavif' (with examples)

How to use the command 'cavif' (with examples)

The ‘cavif’ command is a PNG/JPEG to AVIF converter. It allows users to convert images from JPEG or PNG format to AVIF format.

Read More
How to use the command wine (with examples)

How to use the command wine (with examples)

The wine command allows users to run Windows executables on Unix-based systems.

Read More