Initialize the Project

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 this application, we will initialize a Basic I/O function, which will contain the logic for Custom User Validation and a React web app as the client component. Later, we will also initialize an Advanced I/O function and a Job Function.

Note: Ensure that you enter the function's package name or class name exactly as instructed because the application's code contains the same name.
  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. Navigate using the arrow keys, select your preferred portal, and press the Enter key. If you have no other organizations associated with the account, then the default one will be selected automatically. catalyst_tutorials_jobscheduling_cli_portl_choice
Info: You can find out more about Catalyst’s multi-org portal feature in this help document.
  1. 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 BirthdayGreetings from the list and click Enter.

    catalyst_tutorials_jobscheduling_cli_project_choice
  2. Select Functions and Client using the space bar, then click Enter to initialize.

    catalyst_tutorials_jobscheduling_cli_func_client_sel
  3. The CLI will initiate the function setup. Select Basic IO as the function type to code your Custom User Validation function.

    catalyst_tutorials_jobscheduling_cli_basicio_sel
  4. Select the latest runtime of Node.js as the function stack.

    catalyst_tutorials_jobscheduling_cli_basicio_node_sel
  5. Enter “basic_function” as the package name, “index.js” as the entry point, and your email address as the author, then press Enter. Alternatively, you can press Enter without entering inputs to fill in 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.

    catalyst_tutorials_jobscheduling_cli_basicio_cmpltd

The CLI will now initiate the client setup.

  1. Select React web app and press Enter to initialize your client as a React web app.

    catalyst_tutorials_jobscheduling_cli_react_client_sel
  2. Select JavaScript as the React app type and press Enter.

    catalyst_tutorials_jobscheduling_cli_react_client_js_choice
  3. Enter “birthdaygreetings” as the name of your client package and click Enter. You can also provide any name of your choice. Enter “y” at the prompt to install the required React packages, such as “react”, “react-dom,” and “react-scripts.” These packages will be installed through the Catalyst React plugin (zcatalyst-cli-plugin-react).

    catalyst_tutorials_jobscheduling_cli_react_client_name_dep_enter

The client is now successfully initialized as a React web application.

catalyst_tutorials_jobscheduling_cli_react_client_cmpltd

The client directory will be created in the standard structure in the project directory.

This is the current structure of the Birthday Greetings project’s directory.

catalyst_tutorials_jobscheduling_dir_cur

Now, we will begin initializing the Advanced I/O Function and Job Function using the following CLI command in the BirthdayGreetings/functions/ directory:

copy
$
catalyst functions:add

This CLI command will trigger the function set up and allow you to add the required functions to your project directory.

  1. Select the Advanced IO function once the function setup starts.

    catalyst_tutorials_jobscheduling_cli_func_add_advaced
  2. Select the latest runtime of Node.js as the function stack.

    catalyst_tutorials_jobscheduling_cli_func_add_advaced_node_sel
  3. Enter “advance_function” as the package name, “index.js” as the entry point, and your email address as the author, then press Enter. Alternatively, you can press Enter without entering inputs to fill in 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.

    catalyst_tutorials_jobscheduling_cli_func_add_advaced_node_done

The Advanced I/O function has been initialized.

Let’s initialize the Job Function using the same CLI command.

copy
$
catalyst functions:add
  1. Select Job as the function type once the function setup starts.

    catalyst_tutorials_jobscheduling_cli_func_add_job_start
  2. Select the latest runtime of Node.js as the function stack.

    catalyst_tutorials_jobscheduling_cli_func_add_job_node_sel
  3. Enter “dynamic_cron” as the package name, “index.js” as the entry point, and your email address as the author, then press Enter. Alternatively, you can press Enter without entering inputs to fill in 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.

    catalyst_tutorials_jobscheduling_cli_func_add_job_node_cmpltd

All of the required client and function components have been initialized for your application. This is the current structure of the project directory:

catalyst_tutorials_jobscheduling_dir_2

Last Updated 2025-04-01 11:10:20 +0530 +0530