Prepare Your Development Environment for CAP
- How to set up local development Using VS Code
- How to set up your environment for application development
- How to install extensions for VS Code
- How to install all required tools for UI development
- How to create a directory for development
- How to start from an example branch
Prerequisites
- (For Windows) You have to install SQLite tools for Windows. Find the steps how to install it in the CAP documentation in section How Do I Install SQLite.
- (For macOS) You have to install Command-Line Tools for Xcode, cause some node modules need binary modules (
node-gyp
). There are two options to install them:- Using the command line:
xcode-select --install
- Downloading Xcode (a login with your Apple ID and password is required). Search for
Command Line Tools for Xcode
.
- Using the command line:
- Step 1
To earn your badge for the whole mission, you will need to mark all steps in a tutorial as done, including any optional ones that you may have skipped because they are not relevant for you.
This tutorial contains all the installation steps that you would have to do to get started. It’s likely that you have some of the software already installed, so you can just skip those steps.
You can choose the editor to develop your CAP application. If you want to exactly go along with the following tutorials, we recommend using VS Code as an editor.
- Step 2
This tutorial contains a number of command line snippets that need to be pasted into a command line window. All snippets listed for macOS/Linux or without platform information can be executed in the
bash
orzsh
, which are the default shells for these platforms. The Windows snippets are for the Windows Command Line and not for the PowerShell. Windows users are suggested to use theGit BASH
instead, which is part of the Git for Windows installation and contains the basic UNIX command line tools. In theGit BASH
, use the macOS/Linux snippets of the tutorial. VS Code supports the use of theGit BASH
for the integrated command line window (called Terminal in VS Code) as well. - Step 3
Git is the version control system that you need to download the files of this tutorial but also to develop anything in collaboration with others really.
Check whether you already have Git installed. Open a command line window and execute the following command.
Shell/BashCopygit version
You should get an output like:
Shell/BashCopygit version 2.x.x
If not, go to Git downloads, pick the installer appropriate for your operating system and install it.
- Step 4
Node.js is the JavaScript runtime the CAP backend part of the application runs on and that is needed for some of the tools involved to develop the application.
Make sure you run the latest long-term support (LTS) version of Node.js with an even number like 16. Refrain from using odd versions, for which some modules with native parts will have no support and thus might even fail to install.
If you don’t have the required version, go to Node.js download page, pick the installer appropriate for your operating system, and install it. In case of problems, see the Troubleshooting guide for CAP for more details.
In case you don’t know whether you have Node.js installed and whether it has the right version (^16), open a command line window and execute the following command:
Shell/BashCopynode -v
You should get an output like:
Shell/BashCopyv16.x.x
- Step 5
-
Check in a command line window whether you already have the UI5 CLI installed.
Shell/BashCopyui5 --version
-
If you don’t get a version number, install the UI5 CLI.
Shell/BashCopynpm install --global @ui5/cli
-
Verify that the installation was successful by running the version command again.
Shell/BashCopyui5 --version
See SAPUI5 CLI for more details.
-
- Step 6
- Step 7
CAP provides you with all the tools to create your data model with entities and your services. It helps you tremendously to get these services running locally during development with an incredible speed. It also creates the connection to both local databases and databases in the cloud (SAP HANA). It comes with different tooling that is used in this tutorial. You can see the details in the CAP documentation.
-
Install CDS development kit globally in a command line window.
Shell/BashCopynpm install --global @sap/cds-dk
This process takes some minutes installing the
cds
command that you will use in the next steps. On macOS/Linux, you need to follow the steps as described here.If there’s an older
@sap/cds
package already installed on your machine, you have to remove it first. You’ll be instructed to do so. If you run into problems, see the Troubleshooting guide in the CAP documentation for more details. -
To verify that the installation was successful, run
cds
without arguments.This lists the available
cds
commands. -
Check what versions of the CDS libraries have been installed.
Shell/BashCopycds --version
To know what is the latest version of the CAP tooling, see the Release Notes for CAP.
-
- Step 8
- Step 9
You need to install the SAP Language Support extensions for VS Code:
-
Open VS Code.
-
Choose the Extensions icon in the left pane.
-
Type SAP CDS in the search field and choose SAP CDS Language Support from the search results.
-
Choose Install.
-
Restart VS Code after the installation.
Now, the extension is installed in VS Code. If the extension is already installed and enabled in VS Code, it is updated automatically. The VS Code extension comes with a welcome page, which shows latest release notes of CAP. It starts automatically whenever an update arrives for the extension. Later, you can open the page through the Command Palette in VS Code
CDS: Show CAP Release Notes
.Learn more about SAP CDS Language Support Extension:
-
- Step 10
SAP Fiori tools are a number of extensions for VS Code. They mainly support you in developing SAP Fiori elements apps. In this tutorial, you use the so-called SAP Fiori application generator to create an SAP Fiori elements app, you need this for the tutorial Create an SAP Fiori Elements-Based UI.
Additional Documentation:
For macOS you need to install the
code
command in PATH as described in the previous step on how to Install VS Code.You need to install the SAP Fiori tools - Extension Pack extensions for VS Code:
-
Open VS Code.
-
Choose the Extensions icon in the left pane.
-
Type SAP Fiori tools in the search field and choose SAP Fiori tools - Extension Pack from the search results.
-
Choose Install.
-
Restart VS Code after the installation.
After a restart of VS Code, you can check for the tools by invoking View → Extensions and then scrolling through the list of Enabled extensions. They all start with SAP Fiori tools. If the extension is already installed and enabled in VS Code, it’s updated automatically.
Which of these extensions is included in the SAP Fiori tools - Extension Pack?
-
- Step 11
Yeoman is a tool for scaffolding web apps. You’ll need it if you want to carry out the tutorial Add the SAP Launchpad Service.
-
Check in a terminal whether you already have Yeoman installed:
Shell/BashCopyyo --version
-
If you don’t get a version number, install Yeoman:
Shell/BashCopynpm install --global yo
-
- Step 12
If a tutorial has prerequisites, they’re listed at the beginning of the tutorial.
For the tutorial, you need a directory to develop the app and you need access to the template files. We recommend choosing one root directory (that is the tutorial root directory) for both the directory for your app (
cpapp
) and the tutorial directory (tutorial
) with the template files. See the table below:Directory Contents tutorial root directory the directory containing cpapp
andtutorial
tutorial
the directory containing the clone of the tutorial repository tutorial/templates
templates provided by the tutorial repository cpapp
the directory that will contain your application - Step 13
Downloading the tutorial gives you easy access to template files that are required for some tutorials.
Open a command line window.
Navigate to the previously decided tutorial root directory.
Shell/BashCopycd <tutorial root directory>
Clone the tutorial.
Shell/BashCopygit clone https://github.com/SAP-samples/cloud-cap-risk-management tutorial
- Step 14
To be able to perform the steps for CI/CD, you will need a public repository. Currently, SAP Continuous Integration and Delivery supports GitHub and Bitbucket repositories.
We recommend creating a public GitHub repository to save your tutorial application because this is what the tutorial uses. This way, if you have issues with your tutorial application, you can refer to it.
For real application development, you need to consider the right place for your repository, of course.
Go to GitHub and create a new GitHub repository.
Info about branches
For the sake of simplicity, don’t create additional branches in your repository. When initially created, your repository has only one branch - the
main
branch. This is the only branch you need to complete the tutorial. - Step 15
Copy the repository’s URL you have created before.
Open a command line window.
Navigate to the tutorial root directory.
Shell/BashCopycd <tutorial root directory>
Clone your new repository.
Shell/BashCopygit clone <git-repository-url> cpapp
Replace
<git-repository-url>
with your GitHub repository’s URL.
- Step 16
To earn your badge for the whole mission, you will need to mark all steps in a tutorial as done, including any optional ones that you may have skipped because they are not relevant for you.
If you don’t want to start from scratch, but from a specific example of the tutorial, you can copy the required files in your project. Alternatively, you can fork the project and work on the fork.
The name of the prerequisite branch is given on the top of each tutorial that requires code changes.
Look-up the branch in the tutorial.
Open a command line window.
Navigate to the tutorial root directory.
Shell/BashCopycd <tutorial root directory>
Check out the example’s branch.
Shell/BashCopycd tutorial git checkout <branch>
Replace
<branch>
with the name of the branch of the example that you want to start with.Copy all files from the example to a local directory
<project-dir>
, except the.git
directory.Shell/BashCopycp -r .gitignore $(ls -1A | grep -v .git) ../cpapp
If you get an error, make sure you are not using PowerShell to execute the command. Checkout
Step 2: Command Line Interpreters
above to see the recommended command line interpreters for this tutorial.Check out the
master
branch to get access to the template files again.Shell/BashCopygit checkout master
Switch to your app directory.
Shell/BashCopycd ../cpapp
Install required Node.js modules in your app directory.
Shell/BashCopynpm install
- Editors
- Command line interpreters
- Install Git
- Install Node.js
- Install the SAPUI5 command line interface
- Install the Cloud Foundry command line interface
- Add CAP tooling
- Install VS Code
- Install VS Code extensions
- Install SAP Fiori tools Extension Pack
- Install Yeoman
- Create a directory for development
- Download the tutorial
- Create a GitHub repository for your project
- Clone your GitHub repository
- Start from an example branch