At the end of this exercise, you'll have an environment in which to work for the duration of this CodeJam, and the contents of this repository loaded and ready to use.
To have the building blocks for this CodeJam ready to use, you'll need to clone this CodeJam repository and have the contents available in the workspace that you chose in the prerequisites. Your workspace is either going to be a Dev Space in the SAP Business Application Studio (the "primary environment"), or VS Code with a dev container (the "alternative environment").
Follow one of the two subsections here, as appropriate: either for a primary environment or for an alternative environment.
Follow the "Alternative environment" subsection below if you want to use VS Code and a container image.
👉 Via your subscription to the SAP Business Application Studio, create a new Dev Space, choosing the "Full Stack Cloud Application" type, and then make sure it's started up:
Choosing the "Full Stack Cloud Application" brings in some predefined extensions, as you can see from the screenshot, including a CDS Graphical Modeler and the CAP Tools.
You may need to stop existing Dev Spaces to use this one, depending on your subscription access.
👉 Once the Dev Space is started and you're in it, use the "Clone from Git" option in the "Get Started" screen that appears, to clone this repository, following the subsequent prompts to open the cloned repository; specify https://github.com/SAP-samples/cap-service-integration-codejam
as the URL.
At this point your Dev Space will restart.
Follow the "Primary environment" section above if you want to use a Dev Space in the SAP Business Application Studio.
👉 At a command prompt on your local machine, clone this repository into a directory of your choice, and then open VS Code, pointing to that newly cloned repository's directory:
git clone https://github.com/SAP-samples/cap-service-integration-codejam
code cap-service-integration-codejam
Once VS Code has started, and opened the directory, it should notice the dev container configuration file (in the .devcontainer/ directory) and ask you if you want to reopen everything in a container, as shown in the screenshot. Confirm that you want to, by selecting the default answer "Reopen in Container".
If this doesn't happen, check that you have the Dev Containers extension in VS Code - see the corresponding prerequisites section section for details. You might also need to explicitly request this action, by opening the Command Palette and selecting "Dev Containers: Reopen in container".
At this stage, once VS Code has reopened, you need to do one more thing, so that both primary and alternative environments are aligned (and so that the instructions in this CodeJam content don't need to differ between them).
- When you use the "git clone" facility in a Dev Space, the repo is cloned into a directory called
projects/
, which itself lives in the home directory of your user (/home/user/
); in other words, it gets cloned to/home/user/projects/<the-repo>
. - In the VS Code dev container the default username is
node
(notuser
) and the equivalent repo will be in/workspaces/<the-repo>
. So let's align the repo location in your VS Code dev container environment to the Dev Space one.
A /home/node/projects/
directory has already been created for you in the container image.
👉 Create a symbolic link in the /home/node/projects/
directory to point to the repo:
ln -s /workspaces/cap-service-integration-codejam/ $HOME/projects/ \
&& cd $HOME/projects/cap-service-integration-codejam/
You can make sure that everything is OK by checking that you can see the directories inside the repo, via this new projects/
directory in your dev container user's home directory. Here's an example, with what you might expect to see:
$ find -L $HOME/projects -maxdepth 2 -type d
/home/node/projects
/home/node/projects/cap-service-integration-codejam
/home/node/projects/cap-service-integration-codejam/.devcontainer
/home/node/projects/cap-service-integration-codejam/.git
/home/node/projects/cap-service-integration-codejam/.github
/home/node/projects/cap-service-integration-codejam/.reuse
/home/node/projects/cap-service-integration-codejam/.vscode
/home/node/projects/cap-service-integration-codejam/LICENSES
/home/node/projects/cap-service-integration-codejam/assets
/home/node/projects/cap-service-integration-codejam/exercises
/home/node/projects/cap-service-integration-codejam/incidents
/home/node/projects/cap-service-integration-codejam/scripts
Now you should be all set. You are ready to explore service integration with CAP in your dev container.
This and subsequent steps apply to both the primary and alternative environments.
👉 Inside your dev container or your Dev Space, open a terminal, using "Terminal: Create New Terminal" in the Command Palette, and at the prompt, check the version:
cds v
You should see that the CDS development kit is installed. Depending on your workspace, you'll see slightly different output, but it should generally look something like this:
@cap-js/cds-types: 0.2.0
@sap/cds: 7.6.1
@sap/cds-compiler: 4.4.4
@sap/cds-dk: 7.5.1
@sap/cds-dk (global): 7.5.1
@sap/cds-fiori: 1.2.2
@sap/cds-foss: 5.0.0
@sap/cds-mtxs: 1.15.0
@sap/eslint-plugin-cds: 2.6.5
Node.js: v18.14.2
home: /managed-content/globals/pnpm/5/.pnpm/@[email protected][email protected]/node_modules/@sap/cds
The CDS development kit is installed as part of any "Full Stack Cloud Application" type of Dev Space in the SAP Business Application Studio, and for the alternative environment there's a RUN command in the Dockerfile that installs it into the dev container.
We'll be working mostly within the incidents/
directory of this repo, which contains a simple starter CAP project. In there, the package.json
file contains runtime and design time dependencies.
👉 Make sure you're in the incidents/
directory (where package.json
lives):
cd $HOME/projects/cap-service-integration-codejam/incidents/
👉 Now install the dependencies thus:
npm install
You can double check what's installed, with npm list
, which should show you something similar to this:
@acme/[email protected] /home/user/projects/cap-service-integration-codejam/incidents
├── @cap-js/[email protected]
├── @sap/[email protected]
└── [email protected]
At this point you've got an environment in which to work through the rest of the exercises in this CodeJam, you've got the contents of the repository, and you have the CDS development kit installed and ready to use.
- Developing CAP in containers - three ways
- Developing inside a Container
- Cloning repositories in SAP Business Application Studio
- The @sap/cds-dk package on NPM
If you finish earlier than your fellow participants, you might like to ponder these questions. There isn't always a single correct answer and there are no prizes - they're just to give you something else to think about.
- What are the advantages of using container images for development work?
- What is the difference between the
@sap/cds
and@sap/cds-dk
packages?