Uploading Code for SFRA

Previous Step: Building SFRA

You can use the Storefront Reference Architecture (SFRA) command-line upload tool or Eclipse to upload your code. The command-line watch and upload commands are wrappers for the Dwupload project. Download the project from GitHub if you want to contribute.

Using Eclipse to Upload Code

This topic assumes you've already installed Eclipse and UX Studio. It also assumes you've created a workspace.
  1. Create a storefront project by using the command line build option.
  2. Connect to Your Sandbox Server.
  3. Add the storefront-reference-architecture repository app_storefront_base cartridge to your workspace using the procedure to Add an Existing Cartridge to Your Storefront.
  4. Upload Your Cartridges.
Note: The topics linked to by this section are used by multiple getting started work flows. You can use your browser to navigate back to this topic when you are finished with each step.

Using the SFRA Upload Tool

Configure a dw.json file and run the upload tool from the top-level directory of each repository.

  1. In the cartridge you want to upload, locate, or create a dw.json file.

    This file is automatically created if the sgmf-scripts createCartridge build tool command is used to create the cartridge.

    However, for some cartridges, such as the app_storefront_base and modules cartridges provided by Commerce Cloud, you must create the dw.json file and add it to the cartridge.

  2. Create a dw.json file in the top-level folder of the repository, as a sibling of the cartridges directory.

    The dw.json file contains the information required to establish a server connection and the code version to upload your cartridges to.

        "hostname": "yoursandbox-inside-your-realm.demandware.net",
        "username": "yourusername",
        "password": "yourpwd",
        "code-version": "version1"
    Note: If you have set up UX Studio before, this information is the same information you enter for a server connection.
    This file is normally unencrypted. However, because it contains the instance and password data necessary to upload code, you can use extra measures to secure it.
  3. Use the following commands:

    • uploadCartridge: use this command to upload all the cartridges for the repository. The specific commands to use are in the scripts section of the package.json file that is located in your top-level folder.

      npm run uploadCartridge
    • uploadCartridge: use this command to upload a specific cartridge.

      npm run uploadCartridge mycartridge
    • upload: use this command to upload a single file.

      If you use the same commands as the app_storefront_base cartridge, you run:
      npm run upload path/to/my/filename.ext
    • watch: use this command to detect changes to files in your cartridge and automatically upload them to the server.

      If you use the same commands as the app_storefront_base cartridge, you run:
      npm run watch 

      This command makes it simple to have up-to-date code on your Sandbox instance all the time.

  4. Check that your code is actually on the server:
    1. Select Administration > Site Development > Code Deployment.
    2. Click the Code Version link for the code version you specified in the dw.json file.

      If your cartridge was uploaded successfully, it appears in the list of cartridges on the Version Summary page.

Next Step: Configuring SFRA