NPM

NPM install package globally (system-wide)

npm install --global <package_name>
# for example
npm install --global @ui5/cli

NPM install package locally and add as devDependency (in your project) into the package.json file

npm install --save-dev <package_name>
# for example
npm install --save-dev @ui5/cli

NPM install packages found in the package.json file locally in the same folder where You issue

npm install

NPM install a package and add to package.json under dependencies

npm install <package_name>
# for example
npm install @sap/cds-fiori

NPM check outdated Local packages

Open terminal in the folder where the package.json file is located. To see which packages are outdated issue command

npm outdated

NPM update outdated Local packages

npm update

NPM check outdated Global packages

npm outdated -g --depth=0

Updating a single global package

npm update -g <package_name>

Updating all globally-installed packages

npm update -g

Recreate package-lock.json after deleting it

npm install --package-lock-only

List globally installed packages

npm list -g --depth 0

CAP

Install CAP Tooling

npm install --global @sap/cds-dk

Initialize an empty CAP project in the project folder

cds init
npm install

Start CAP Server

cds watch

Add SAP HANA client and configuration to your project

# This will extend package.json to have HANA as CDS requirement for production, 
# but still SQL Lite will be used locally during development
# also adds files db/src/.hdiconfig.json, db/undeploy.json
cds add hana --for production

Set up User Authentication and Authorization (XSUAA)

# this will create xs-security.json including role templates and 
# update package.json setting cds db authentication in production to xsuaa, 
# besides adding required dependencies
cds add xsuaa --for production

Generate MTA deployment descriptor (mta.yaml)

# creates mta.yaml based on the package.json file with initial settings
cds add mta

Update xs-security.json based on new roles / role templates

cds compile srv/ --to xsuaa > xs-security.json

Bind CAP Application to a HANA DB using the credentials which were generated by BAS/SAP HANA Database Explorer into the db/.env file.
This makes possible to run your CAP service locally in BAS without the need to deploy it to BTP dev space, but using the HANA Cloud of the dev space.

image-1-1024x681 Command Line Commands for SAP Development
Pasted Command Line Commands for SAP Development
cds bind -2 MyHANAApp-dev:SharedDevKey

You can run the CAP app using the bound HANA Cloud instance Afterwards with the following switch

cds watch --profile hybrid

Deploy DB Artefacts to HANA after connecting/binding in BAS under the run configuration is done

BAS-Run-Config-with-HANA-Connection Command Line Commands for SAP Development
cds deploy --to hana:cpapp-db --no-save

UI5 / Fiori

Install UI5 / Fiori Tooling

# UI5 CLI/Tooling, https://sap.github.io/ui5-tooling/
npm install --global @ui5/cli
# Fiori Tools - UI5 Tooling, https://www.npmjs.com/package/@sap/ux-ui5-tooling
npm install --global @sap/ux-ui5-tooling

Install Yeoman

npm install --global yo

Cloud Foundry CLI

# Set the Cloud Foundry API endpoint
cf api <API Endpoint of your landscape>
# forex
cf api https://api.cf.us10-001.hana.ondemand.com
# Log in
cf login --sso
# Set Organization and Space
cf target -o ORG -s SPACE
# forex
cf target -o 11817002trial -s dev 

Undeploy Application

Hope You are sure what you are doing !

# This will delete application and services instance as well => ALL DATA AS WELL
cf undeploy <yourapp> --delete-services --delete-service-keys --delete-service-brokers
# Shortcut to above is, when package.json has the undeploy script 
# (move mouse above in BAS/VSCode and Run it directly)
npm run undeploy

# to remove only the application
cf undeploy <yourapp>

Retrieve logs for a given application

# Last log entries
cf logs --recent <appname>
# All log entries
cf logs <appname>

Deploy MTA

cf deploy <multi_target_archive_file>
# forex
cf deploy myApp_1.0.0.mtar

Start a stopped HANA Cloud Instance

cf update-service <name_of_the_hana_trial_instance> -c '{"data":{"serviceStopped":false}}'

HANA CLI

# Install Command Line Utility
npm install -g hana-cli

Inspect a DB Object, like a View and dump out definition in CDS format

hana-cli inspectView -v V_INTERACTION -o cds

Output:

@cds.persistence.exists 
@cds.persistence.calcview 
Entity ![V_INTERACTION] {
key     ![ID]: Integer  @title: 'ID: ID' ; 
        ![PARTNER]: String(10)  @title: 'PARTNER: PARTNER' ; 
        ![LOG_DATE]: String  @title: 'LOG_DATE: LOG_DATE' ; 
        ![BPCOUNTRY_CODE]: String(3)  @title: 'BPCOUNTRY_CODE: BPCOUNTRY_CODE' ; 
        ![TEXT_ID]: String(10)  @title: 'TEXT_ID: TEXT_ID' ; 
        ![LANGU]: String(2)  @title: 'LANGU: LANGU' ; 
        ![LOGTEXT]: String(1024)  @title: 'LOGTEXT: LOGTEXT' ; 
}

Cloud MTA Build Tool

Installation of the Tool

Prerequisite is make ( just for windows )

# Install the tool using npm
npm install -g mbt
# Install CF CLI Plugin for that as well
cf install-plugin multiapps

Build MTA Module

mbt build -t ./

Git

Clone Git repository into a given subfolder

git clone <git-repository-url> <folder_name>
# forex
git clone https://github.com/attilaberencsi/capnodejsfullstack.git cpapp

Initialize local Git repository in the project folder

git init

Unset Credentials when different credentials are needed

git config --local --unset credential.helper
git config --global --unset credential.helper

Set credential timeout

git config --global credential.helper "cache --timeout=86400"

Store credential permanently

git config credential.helper store

Checkout Branch. Issue this in the project folder, where the .git folder is also present (windows)

git checkout <branch>
# forex 
git checkout main

Linux

Remove folder

rm -rf

Share this content: