Web Apps - CLI Installation
ZET is a CLI tool to help developers build client-based apps(marketplace apps) and test it locally. Developer's can write code in local app and test it on the fly without uploading the App files to server. ZET will help the developers in the following ways:
- Automatically create the project template with basic necessary files & folder structure.
- Run local http server to the serve the app contents.
- Validate your app.
- Package your app for upload.
Installation of necessary components
Pre-requisites:
- Download the nodejs source code from "https://nodejs.org/en/download/".
- Once Node is installed, verify it by running the following command.
$ node -v
$ npm -v
CLI Installation
Run the following command to install the zet CLI node package.
$ npm install -g zoho-extension-toolkit
Note:
- Use sudo before executing the command if you don't have permission to install the tool.
- -g option makes sure that, the module is installed globally. hence, the CLI command can be accessed anywhere.
Run the following command to ensure that the installation is successful.
$ zet // Help information about 'zet' command will be shown.
Create a project
Run the following command to create new project.
$ zet init
This command will show the list of Zoho Services for which you wish to create project template. Select Catalyst as the service.
To verify whether the server is started successfully, open the following URL in the browser http://localhost:5000/plugin-manifest.json or http://localhost:5000/app/app_file.html
Include Resources
All the files that are required for rendering your web app appears inside the "app" folder of your project.
Starting the Server
To start a local HTTP server that allows to run your app locally and to test it in your sandbox instance, run the following command,
$ zet run
This will run the HTTP server in your local machine in the port number 5000. The port should not be occupied with any other process before starting the server.
To verify whether the server has started successfully, open the following URL in your web browser:
http://127.0.0.1:5000/app/app_file.html
Validation and Packaging the Web app
When we run the below command, it will validate the application source to make sure it follows the guidelines provided in the section <>.
$ zet validate
This will provide the validation result. We need to fix if there is any validation errors mentioned. Without fixing the validation issues, the app can not be uploaded in the Zoho developer console since the same code check will happen when we upload the application in zet service.
Packaging
The project folder which you are working on contains the app sources also some node modules which is needed for local testing. When you upload the app in Zoho marketplace, make sure that the zip includes only the application's relevant files & folders.
To make packaging easy, a command called 'pack' which will create a zip file with app relevant files alone (excluding node module related files), is provided. This zip is now ready to be uploaded.
$ zet pack