Initialize the Project from the CLI

You can now begin working on your Catalyst project from the CLI. The first step is to initialize the project in an empty directory. This will be the home directory of your project and all of the project files will be saved in it.

You can learn more about this from the Project Directory Structure help page. You can learn about initializing a project in detail from the CLI help documentation.

For the news application, we will initialize a cron function and the client, and then add an Advanced I/O function to the project directory.

  1. Create a folder for the project on your local machine and navigate to it from the terminal.

  2. Initialize a project by executing the following command from that directory:

copy
$
catalyst init
  1. Select your preferred portal using the arrow-keys, and press Enter to select your preferred portal. cron_catalyst_init_portal_select

  2. The CLI will now ask you to associate a Catalyst project with the directory. Associate it with the project that we created earlier from the console. Select NewsApp from the list and press Enter. cron_project_select

  3. Select Client and Functions using the space bar. Press the Enter key to initialize. cron_catalyst_init

  4. The CLI will initiate the function setup. Select Cron as the function type. cron_functions_setup

  5. Select the latest runtime of Java based on your requirements as the function stack, and press Enter. cron_java_functions

  6. Enter “NewsFetch” as the folder name and press Enter. Enter “FetchNews” as the class name and press Enter. cron_function_init_complete

The CLI will download and install the Catalyst Java SDK on your local system.

Note: Ensure that you enter the package name, or class name and folder name, exactly as instructed, because the application's code contains the same names.
  1. The CLI will initiate the client set up next. Select Basic web app as your client type. cron_client_select

  2. Enter ‘NewsAppClient’ as the name for the client package and press Enter. You can enter any name you need. cron_client_setup
    The client directory will be created in the standard structure. Catalyst initialization is now complete.

Let’s now add an additional Advanced I/O function to the project directory.

  1. To add an additional function, execute the following command from the project directory:
copy
$
catalyst functions:add
  1. Select AdvancedIO as the function type and press Enter. cron_advanced_function

  2. Select the latest runtime of Java based on your requirements as the function stack, and press Enter. cron_advanced_java_func

  3. Enter “NewsApp_AIO” as the folder name and press Enter. Enter “DatastoreFetch” as the class name of the Java function and press Enter. cron_java_function_add

The CLI will install the Catalyst Java SDK on your local system and update the information in the configuration file.

Note: Ensure that you enter the package name, or class name and folder name, exactly as instructed, because the application's code contains the same names.

Your project directory is now set up with the client directory and the functions directory along with configuration files and dependencies. The functions directory contains both the Cron and Advanced I/O functions in individual folders. The project directory also contains the catalyst.json configuration file and a hidden catalyst.rc file.

This is the structure of the NewsApp project’s directory. cron_java_directory

Last Updated 2023-12-15 18:54:08 +0530 +0530