CDS Commands

We will see most common commands which are used to create, build and deploy the cap app.

Creating a CAP App -

Terminal
cds init <Project_Name>

Now, go inside the Folder, and install the dependencies -

Terminal
cd <Project_Name>
npm install

Generate csv file to store sample data for Schema in db -

Terminal
cds add data

Deploy the db data in SQLite server -

add the below line of code in package.json file below the script object

package.json
"cds" : { "requires" : {
    "db" : {
        "kind" : "sqlite",
        "credentials: " : { "url" : "db/managementCAP.sqlite" }
        }
    }
} 

Once added, Use the below line of command to deploy it -

Terminal
cds deploy --to sqlite:./db.sqlite

To add Hana, mta file, xsuaa and approuter file -

Terminal
cds add hana,mta,xsuaa,approuter --for production

Command to update and lock the package lock file -

Terminal
npm update --package-lock-only

To Build and generate Build File -

Terminal
mbt build -t gen --mtar mta.tar

To Deploy the Build File -

Terminal
cf deploy gen/mta.tar

To Un-Deploy the Project -

Terminal
cf undeploy <project-name> --delete-services --delete-service-keys

You can modify the scripts of your package.json and add all the required commands like below -

package.json
"scripts" : {
    "start" : "cds-serve",
    "dev" : "cds-serve",
    "build" : "mbt build -t gen --mtar mta.tar",
    "deploy" : "cf deploy gen/mta.tar",
    "undeploy" : "cf undeploy <project-name> --delete-services --delete-service-keys"
}