About the Project Structure in SuiteCloud CLI for Node.js

When you create a SuiteCloud project with SuiteCloud CLI for Node.js, its structure is different from projects created with SuiteCloud IDE plug-ins or SuiteCloud CLI for Java. In SuiteCloud CLI for Node.js, your project folder has the suitecloud.config.js file and a src folder, which stores all your SuiteScript files, SDF custom objects, and project-related config files. You can use SuiteCloud projects created with 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 with SuiteCloud Extension for Visual Studio Code follow the same structure.

SuiteCloud Project Types in SuiteCloud CLI for Node.js

Here are some examples showing the structure of 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 of 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 in your project folder.

Suitecloud.config.js File

This file is created when you run suitecloud project:create —i and defines the default folder for your project. By default, the structure of the file looks like this:

              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 right names, see SuiteCloud CLI for Node.js Commands Reference.

Suitecloud.config.js File Entry Points

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

  • beforeExecuting — The code runs before the command runs.

  • onCompleted — The code runs after the command finishes successfully (without errors).

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

Suitecloud.config.js Customizations

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

  • Set command options so you don't have 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 as default.

    For example, if you want to apply content protection every time you deploy a SuiteApp, add this code:

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

    Use the same option names as SuiteCloud CLI for Node.js. To make sure you use the right 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 to any of the three entry points. These messages show up along with SuiteCloud CLI for Node.js logs. To display a custom message, create a function on an entry point and log it to the console.

    For example, if you want to show a message in your console every time you import files, add this code:

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

    For example, if you want to run all your commands from the src folder, but deploy from the dist folder, add this code:

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

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

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

Suitecloud.config.js File Example

Here's 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, these customizations have been set:

  • project:deploy command

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

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

    • When the command finishes without errors, you'll see this message in the console: Eureka! The deployment was a success.

    • If there's an error, you'll see this message in the console: Houston, we've had a problem here. The deployment failed.

  • project:validate command — This command runs from the dist folder, instead of the default src folder.

  • project:adddependencies command — This command runs from the dist folder, instead of the default src folder.

Related Topics

General Notices