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 Node.js based on your requirements as the function stack, and press Enter. cron_nodejs_functions

  6. Enter “NewsApp” as the package name, “index.js” as the entry point, and your email address as the author and press Enter. You can press Enter to fill in the default values. cron_node_cron_func

The CLI will download and install the Catalyst Node.js 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 Node.js as the function stack, and press Enter. cron_advance_node_choice

  3. Enter “news_app_function” as the package name, “index.js” as the entry point, and your email address as the author and press Enter. You can press Enter to fill the default values. cron_advanced_node_func

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 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_nodejs_directory

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