Creating Web App

Version added 2018-04-04 17:26:00| Modified 11-Apr-2018

External web apps that must be deployed on a webOS OSE device, can be created and deployed using CLI commands that are provided by webOS OSE SDK. This topic describes the steps to create an external web app. For detailed information on the commands, see Command Line Interface.

If you want to add a JS service to your web app, see Creating JS Services..

 

Step 1: Create Web App Project

You must start by creating a project using one of the available web app templates. These templates provide a starting point for developing the web app.

To create a basic web app, execute the following command:

ares-generate -t basic sampleApp

In the above command:

  • <basic> is the name of template that creates a basic web app.

  • <sampleApp> is the web app directory which is created in the current directory.

The web app directory (sampleApp) has the following files: 

Directory / File

Description

webOSjs-0.1.0

webOS library directory to call LS2 API.

appinfo.json

Configuration file that includes metadata for the web app.

icon.png

The icon image file. Can be replaced with relevant icon.

largeIcon.png

The large icon image file. Can be replaced with relevant icon.

index.html

Web application main page. This page only shows "Hello World" text on screen.

If you have a web app that you want to deploy on a webOS OSE device, you must add the 'appinfo.json' file to the app root directory. To create this file, on the SDK CLI, enter the following command:
ares-generate -t webappinfo webApp

See Step 2 below for more information on the 'appinfo.json' file.

 

Step 2: Configure Web App

The details or metadata of the web app must be specified in the appinfo.json file. This file is automatically created when you create a web app project. For details, see appinfo.json.

The CLI provides the 'appinfo.json' file template as below.

{
    "id": "com.domain.app",
    "version": "0.0.1",
    "vendor": "My Company",
    "type": "web",
    "main": "index.html",
    "title": "new app",
    "icon": "icon.png",
    "largeIcon": "largeIcon.png",
}

 

Step 3: Develop Web App

Design and implement the source code for the web app.

By default, the basic web app template includes some basic code that prints a "Hello World" message. Therefore, if you want to create a demo web app to test this process, you can skip this step and proceed.

 

Step 4: Package Web App

After developing the web app it must be packaged as an IPK file. Make sure the 'appinfo.json' file is available, as it is required when packaging a web app for webOS OSE.

To package the web app use the ares-package command. The IPK file is stored in the current directory.

General usage:

ares-package APP_DIR SERVICE_DIR

In the above command, APP_DIR and SERVICE_DIR mean app and service directories respectively. You can use an absolute or relative path for both APP_DIR and SERVICE_DIR.

Sample usage:

  • Packaging web app only (relative path):

    Windows: ares-package sampleApp

    Linux/MacOS: ares-package ./sampleApp

  • Packaging web app with one JS service (relative path):

    Windows: ares-package sampleApp sampleService

    Linux/MacOS: ares-package ./sampleApp ./sampleService

  • Packaging web app with multiple JS services (relative path):

    Windows: ares-package sampleApp sampleService sampleServiceNew 

    Linux/MacOS: ares-package ./sampleApp ./sampleService ./sampleServiceNew

  • Packaging web app with JS service (absolute path)

    Windows: ares-package c:\samples\sampleApp c:\samples\sampleService

    Linux/MacOS: ares-package ~/samples/sampleApp ~/samples/sampleService

 

Step 5: Install Web App

Make sure the webOS OSE target device is running.

To install the web app on the target device, execute the following command:

ares-install --device device ./com.domain.app_0.0.1_all.ipk

In the above command:

  • <device> is the name of the target device., which can be obtained as follows:

    • Get a list of target devices using this command: ares-setup-device –list

    • Get a list of target device (with all properties) using this command: ares-setup-device –listfull

    • If the required target device does not exist, add a new device or modify the properties of an existing device. For details, see Command Line Interface.

  • <./com.domain.app_0.0.1_all.ipk> is the name of the IPK file that is generated after packaging the app in previous step.

You can verify the installation by checking if the web app ID (in this case; com.domain.app) is available in the output of the following command: 

ares-install --device device --list
You can remove the app from the device, by using the 'ares-install' command as follows:
ares-install --device device --remove com.domain.app

 

Step 6: Launch Web App

To launch the web app on the target device, execute the following command:

ares-launch --device device com.domain.app

In the above command:

  • <device> is the name of the target device. This is the same device on which the app was installed in previous step.

  • <com.domain.app> is the app ID that is available after installing the app.

After executing the above command, check the target device to see if the app is running.

You can close the app, by using the 'ares-launch' command as follows:
ares-launch --device device --close com.domain.app
Except as noted, this content is licensed under Creative Commons Attribution 4.0 and sample code is licensed under Apache License 2.0.