About the Project Structure in SuiteCloud CLI for Node.js

When you create a SuiteCloud project through SuiteCloud CLI for Node.js, its structure is different from projects created in SuiteCloud IDE plug-ins and SuiteCloud CLI for Java. In SuiteCloud CLI for Node.js, the project folder contains the suitecloud.config.js file and the src folder, which stores all your SuiteScript files, SDF custom objects, and project-related configuration files. You can use SuiteCloud projects created through SuiteCloud CLI for Node.js in SuiteCloud IDE plug-in for WebStorm and in SuiteCloud Extension for Visual Studio Code.

For more information about SuiteCloud project files, see SuiteCloud Project Files in SuiteCloud CLI for Node.js.

Note:

SuiteCloud projects created in SuiteCloud Extension for Visual Studio Code follow the same structure.

SuiteCloud Project Types in SuiteCloud CLI for Node.js

The following examples outline the structure of the different SuiteCloud project types:

  • Account customization projects

                    myACP
       > src
          > AccountConfiguration
          > FileCabinet
             > SuiteScripts
             > Templates
             > Web Site Hosting Files
             > Objects
             > Translations
          deploy.xml
          manifest.xml
          project.json
    suitecloud.config.js 
    
                  

    To see how to create an account customization project in SuiteCloud CLI for Node.js, watch the following video:

    For more information, see Account Customization Projects.

  • SuiteApp projects

                    com.mycompany.mysuiteapp
       > src
          > FileCabinet
             > SuiteApps\com.mycompany.mysuiteapp
             > Web Site Hosting Files
          > InstallationPreferences
          deploy.xml
          manifest.xml
          project.json
    > Objects
    > Translations
    suitecloud.config.js 
    
                  

    To see how to create a SuiteApp project in SuiteCloud CLI for Node.js, watch the following video:

    For more information, see SuiteApp Projects.

Note:

If you added unit testing with Jest when creating your account customization project or SuiteApp, your project will also contain the __tests__ and node_modules folders.

For more information about the structure of SuiteCloud projects, see SuiteCloud Project Structure and File Components.

To see an example on how to use SuiteCloud CLI for Node.js, watch the following video:

SuiteCloud Project Files in SuiteCloud CLI for Node.js

Your project configuration is stored in the suitecloud.config.js file within the project folder.

Suitecloud.config.js File

This file is created when you run suitecloud project:create —i and defines the default folder where the project is located. By default, the structure of the file is as follows:

              module.exports = {
         defaultProjectFolder: "src",
         commands: {}
}; 

            

You can use this file to add customizations to SuiteCloud CLI for Node.js commands. You can add code to inject logic such as defining different folders for specific commands, setting command flags, or adding unit tests.

Note:

Use the same command names used by SuiteCloud CLI for Node.js. To make sure you use the correct names, see SuiteCloud CLI for Node.js Commands Reference.

Suitecloud.config.js File Entry Points

To trigger command customizations, you can use the following entry points on different commands:

  • beforeExecuting — The code is executed before the command runs.

  • onCompleted — The code is executed after the command has run successfully (without any errors).

  • onError — The code is executed if an error is thrown.

Suitecloud.config.js Customizations

The suitecloud.config.js file lets you perform the following customizations:

  • Set command options to avoid having to pass their value every time you run the command. To call a command option, enter options.argument.[optionName]. Then, set the value you want to have as default.

    For example, if you want to apply content protection every time you deploy a SuiteApp, enter the following code:

                        commands: {
          "project:deploy": {
            beforeExecuting: options => {
           options.arguments.applycontentprotection = true;
          return options;
        },
      },
    }; 
    
                      
    Note:

    Use the same option names used by SuiteCloud CLI for Node.js. To make sure you use the correct names, see SuiteCloud CLI for Node.js Commands Reference, and check the Option table in the command’s section you want to customize. You can also see the possible values of the options.

  • Add messages on any of the three entry points. These messages are displayed in addition to SuiteCloud CLI for Node.js logs. To display a custom message, create a function on an entry point and log it into the console.

    For example, if you want to display a message in your console every time you import files, enter the following code:

                        commands: {
            "file:import": {
                beforeExecuting: myMessage => {
                    console.log("We're importing SuiteScript files...");
                },
            },
    }; 
    
                      
  • Set a project folder different from the default one.

    For example, to run all your commands from the src folder, but deploy runs from the dist folder, enter the following code:

                        module.exports = {
        defaultProjectFolder: 'src',
        commands: {
            "project:deploy": {
                projectFolder: 'dist',
            },
        },
    }; 
    
                      
    Note:

    The folder you define needs to be inside of the project folder.

  • Add your own code to run unit tests, for instance. You can add it on any of the three entry points.

Suitecloud.config.js File Example

The following is an example of a customized suitecloud.config.js file.

                module.exports = {
    defaultProjectFolder: 'src',
    commands: {
        "project:deploy": {
            projectFolder: 'dist',
            beforeExecuting: async options => {
                options.arguments.validate = true;
                // You can run some build processes or unit tests here.
                // You should return the options object or a Promise that returns the options object on resolve.
                return options;
            },
            onCompleted: output => {
                console.log("Eureka! The deployment was a success.");
            },
            onError: error => {
                console.log("Houston, we've had a problem here. The deployment failed.");
            },
        },
        "project:validate": {
            projectFolder: 'dist',
        },
        "project:adddependencies": {
            projectFolder: 'dist',
        },
    },
}; 

              

In this example, the following customizations have been defined:

  • project:deploy command

    • The command is run from the dist folder, instead of the src folder, which is the default.

    • Before the command runs, the project is validated locally.

    • When the command has run and no error is thrown, the following message is displayed in the console: Eureka! The deployment was a success.

    • If an error is thrown, the following message is displayed in the console: Houston, we've had a problem here. The deployment failed.

  • project:validate command — The command is run from the dist folder, instead of the src folder, which is the default.

  • project:adddependencies command — The command is run from the dist folder, instead of the src folder, which is the default.

Related Topics

SuiteCloud CLI for Node.js Guide
SuiteCloud CLI for Node.js Installation Prerequisites
Supported SuiteCloud CLI for Node.js Versions
Supported Command-Line Interpreters for SuiteCloud CLI for Node.js
Installing SuiteCloud CLI for Node.js
Setting Up SuiteCloud CLI for Node.js
Debugging in Visual Studio Code using SuiteCloud CLI for Node.js
SuiteCloud Unit Testing with Jest

General Notices