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 Museum Finder application, we will initialize the client and the Basic I/O function components initially. We will then add the other functions to the project directory as discussed in the Introduction.

  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 Client and Functions using the space bar. Press the Enter key to initialize.

  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 MuseumFinder from the list and press Enter.

  3. The CLI will initiate the function setup. Select BasicIO as the function type.

  4. Select the required runtime of Java as the function stack.

  5. Enter the name of the Java function and the folder as “RatingProcessor” and press Enter. This is also its reference name. Enter the same name as its main class name as well, and press Enter. The Catalyst Java SDK will now be downloaded to your system.

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

  1. The CLI will initiate the client set up next. Enter “MuseumFinderClient” as the name for the client package and press Enter. You can enter any name you need.

    The function and client directories will be created in the standard structure. Catalyst initialization is now complete.

Add Functions to the Project

Let us now add the other functions to the project.

  1. Execute the following command from the project directory to add a new function to it:
copy
$
catalyst functions:add

  1. The CLI will initiate the function setup. Follow the same steps as function initialization discussed above. Select BasicIO as the function type and the required version of Java as the function stack. Provide the function name and class name as “TravellerTypeRatingProcessor”.

    Now, add two other Basic I/O functions of the Java stack in the same manner. Provide their function names and class names as “MergeDataSet” and “Mailer” respectively.


    Note: Ensure that you enter the main class name and the function's name of all the functions exactly as instructed, because the application's code contains the same names.

The Java functions are now created.


Let us now add the Node.js function to the project in the same manner as above.

  1. Execute the following command from the project directory again:
copy
$
catalyst functions:add
  1. The CLI will initiate the function setup. Select AdvancedIO as the function type and node10 as the function stack. Provide the package name as “circuit”, “index.js” as the entry point, and your email address. You can press Enter to fill the default values.

    The CLI will prompt the initialization of the Node dependencies. Press Y to confirm the installation, and press Enter to confirm your choice. The Node modules will be installed.

    Note: Ensure that you enter the function's package name exactly as instructed, because the application's code contains the same name.

We have now initialized all the functions and client components in the project.


The client directory and the functions directory will be created in your project directory with the configuration files and dependencies, along with the catalyst.json and a hidden catalyst.rc file.

This is the structure of your project directory.


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