Freshworks CLI

The Freshworks Command-Line Interface (CLI) enables you to build, test, and package apps to are published in Freshworks Marketplace.

  • To view the list of CLI commands, after you install the CLI, type fdk and press Enter.
  • To view information about a CLI command, run the following command. $ fdk COMMAND [-h or --help]
  • To obtain detailed logs that pertain to a CLI command, run the following command.
  • $ NODE_DEBUG=fdk fdk COMMAND
Create

The command creates an app in the specified directory, based on the default app template. If no directory is specified, the app is created in the current directory.

Note: Ensure that the directory in which the app is to be created is empty.
$ fdk create [--app-dir DIR] [--products PRODUCT] [--template TEMPLATE]

Options Usage
--app-dir To specify the absolute or relative path of the project directory.
--products To specify the product for which the app is created. If not specified, you will be prompted to select a product.
--template To specify the template. If not specified, you will be prompted as shown:

Example 1
To create a Freshteam app in the current directory, run the following command. Ensure that the current directory is empty. $ fdk create --products freshteam --template your_first_serverless_app

Sample Output
A Freshteam app is created based on the your_first_serverless_app template with the following files.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<current_app_directory> ├── README.md ├── config │ ├── iparam_test_data.json │ └── iparams.json ├── manifest.json └── server ├── lib │ └── handle-response.js ├── server.js └── test_data └── onEmployeeCreate.json 4 directories, 7 files
EXPAND ↓

Example 2
To create a Freshteam app in the myfirstapp directory, run one of the following commands. $ fdk create --app-dir ./myfirstapp $ fdk create --app-dir /Users/user/myfirstapp

Output
The app files are created in the /Users/user/myfirstapp directory.

Generate

This command is used to generate app files with a specific template for an existing app that was created by using the create command.

  • After you create an app, run the following command. $ fdk generate The list of the following files is displayed.
    • oauth_config.json: Contains the configuration parameters, such as client_id, client_secret, authorize_url, token_url, and account/agent scope, required for OAuth-based authentication.
    • iparams.json: Contains the installation parameters, such as iparam name and type of iparam, whose values are set when the app is installed.
    • iparams.html: Contains the html code to build the Custom Installation page. You can enter the page title, select the product css to link, and choose to add jquery, fresh_client.js, and iparam.js and iparam.css.
    • server.js: Contains the event registration and callback methods. You need to enter the names of the events and callback functions.
    • manifest.json: Contains app information such as version, product, location, and so on. You need to select the product and app location.
  • Select a file and enter the appropriate parameter values. The corresponding file is generated based on the values.
Run

The command starts the local server and enables you to test the app.

$ fdk run [--app-dir DIR]

Option Usage
--app-dir To specify the absolute or relative directory path to the app project that is to be deployed on the local server.

If you are running a serverless app that contains dependencies, the packages defined in manifest.json are automatically installed.

After testing, press Control + C to stop the server. A code coverage summary that indicates the extent of testing is displayed. The following coverage summary shows an example of extensive testing.

1
2
3
4
5
6
======================= Coverage summary ======================== Statements : 98.18% ( 54/55 ) Branches : 100% ( 4/4 ) Functions : 84.62% ( 22/26 ) Lines : 98.18% ( 54/55 ) =================================================================
Note: When apps are submitted for the App Review process, ensure that each component in the coverage summary is at least 80%. For more information, see Code coverage.

Example 1
To deploy the app project located in the current directory, run the following command. $ fdk run

Output

Starting local testing server at http://*:10001/
Append 'dev=true' to your Freshteam account URL to start testing
e.g. https://domain.freshteam.com/dashboard?dev=true
Quit the server with Control-C.

Example 2
To deploy the app project located in the myfirstapp directory, run the following command. $ fdk run --app-dir /Users/user/myfirstapp The output is the same as that for Example 1.

Example 3
To deploy a serverless app from a different directory, run the following command. $ fdk run --app-dir /Users/user/myfirstapp

Output

Starting local testing server at http://*:10001/
Append "dev=true" to your Freshteam support URL to start testing
e.g. https://domain.freshteam.com/helpdesk/tickets/1?dev=true
Quit the server with Control-C.

To test the serverless component of your app, visit - http://localhost:10001/web/events

Validate

This command validates whether the app code is error free. If there are errors in the code, corresponding violations are displayed after the command is run.

$ fdk validate [--app-dir DIR] [--fix]
Option Usage
--app-dir To specify the absolute or relative path to the app directory that contains the files to be validated.
--fix To fix all the lint errors for which auto-fix support is available.
Pack

This command creates an app package file that can be submitted for the App Review process.

$ fdk pack [--app-dir DIR]

Option Usage
--app-dir To specify the absolute or relative path to the app project directory.

After you run the pack command, a dist/<app_directory>.zip file is generated. To publish the app in Freshworks Marketplace, upload the generated file in the Freshteam Developer portal.

Example 1
To pack the app files located in the app project directory, run the following command. $ fdk pack

Output

App packed successfully at /dist/<current_app_directory>.zip
Upload this file to the marketplace by following the instructions at https://developers.freshteam.com/docs/marketplace-listing/

Example 2
To pack the app project files located in the myfirstapp directory, run the following command. $ fdk pack --app-dir /Users/user/myfirstapp

Output

App packed successfully at /dist/myfirstapp.zip
Upload this file to the marketplace by following the instructions at https://developers.freshteam.com/docs/marketplace-listing/

Version

The command displays the installed and latest CLI version numbers. $ fdk version

Output

Installed: 6.0.0
Latest: 6.5.4
To install the latest version type "npm install https://dl.freshdev.io/cli/fdk-6.5.4.tgz -g"