@cbs-consulting/generator-btp
v1.3.3
Published
CBS Best Practice Generator - Yeoman generator for bootstrapping CAP/UI5 projects with TypeScript, ESLint, and other essential configurations
Readme
CBS Best Practice Generator
A modular Yeoman generator for bootstrapping and enhancing SAP CAP and UI5 projects with industry best practices, including TypeScript, linting, formatting, dev containers, and Azure DevOps CI/CD configuration.
Overview
This generator provides a suite of modular sub-generators that can be used together or independently:
- 🎯 Main Entry Point - Interactive menu to select which generator to run
- 🚀 CAP Generator - Complete CAP project setup with TypeScript, MTA, dev container, and optional Azure DevOps
- 🎨 UI5 Generator - Add best practices to existing UI5 applications (ESLint, UI5lint, TypeScript)
- 🐳 Devcontainer Generator - VS Code dev container for consistent development environments
- ☁️ Azure DevOps Setup - Automated scripts for configuring branch policies, merge strategies, and CI/CD pipelines
Prerequisites
The CAP generator requires @sap/cds-dk to be installed globally, as it invokes cds init directly during execution:
npm install -g @sap/cds-dkInstallation
Install Yeoman and this generator globally:
npm install -g yo @cbs-consulting/generator-btpOr install as a dev dependency:
npm install --save-dev yo @cbs-consulting/generator-btpQuick Start
Interactive Mode (Recommended)
Run the generator and select from the menu:
yo @cbs-consulting/btpDirect Generator Access
Invoke specific generators directly:
# Bootstrap a new CAP project (includes devcontainer + optional Azure DevOps)
yo @cbs-consulting/btp:cap
# Add best practices to existing UI5 apps
yo @cbs-consulting/btp:ui5
# Add devcontainer only
yo @cbs-consulting/btp:devcontainer
# Add Azure DevOps setup scripts only
yo @cbs-consulting/btp:setup-azure-devopsGenerators
🚀 CAP Generator
Purpose: Bootstrap a complete CAP project with all best practices.
Requires
@sap/cds-dkinstalled globally (npm install -g @sap/cds-dk).
What it does:
- Runs
cds initwith TypeScript, MTA, XSUAA, HANA, and sample content - Configures ESLint and Prettier (using @cbs-consulting/tools)
- Sets up git workflows with advanced aliases (ticket-based branches, PR automation)
- Adds pre-commit hooks (linting, formatting) with simple-git-hooks
- Generates MTA deployment descriptors with environment-specific extensions (dev/test/prod)
- Configures VS Code with 30+ recommended extensions
- Includes devcontainer generator (always)
- Includes setup-azure-devops generator (optional, if selected)
Key files added:
.gitignore,.gitconfig.aliases,.gitattributes,.npmrceslint.config.mjs,prettier.config.mjsmta.yaml+mta-ext/{dev,test,prod}.mtaextazure-pipelines.yaml(if Azure DevOps enabled).devcontainer/folderscripts/setup-azure-devops/folder (if Azure DevOps enabled)
Usage:
mkdir my-cap-project
cd my-cap-project
yo @cbs-consulting/btp:cap🎨 UI5 Generator
Purpose: Add best practices to existing UI5 applications.
What it does:
- Auto-detects UI5 apps in the
app/folder (by findingui5.yaml) - Adds ESLint and UI5lint configurations per app
- Configures TypeScript to work with CAP-generated models
- Adds npm scripts for linting and UI5-specific linting
Key files added (per app):
eslint.config.mjs,ui5lint.config.mjs- Updates
package.jsonandtsconfig.json
Usage:
# Run from CAP project root with app/ folder
yo @cbs-consulting/btp:ui5🐳 Devcontainer Generator
Purpose: Set up VS Code dev container for consistent development environments.
What it does:
- Creates
.devcontainer/configuration using CBS Docker image - Pre-configures 30+ VS Code extensions
- Auto-installs Cloud Foundry and Azure DevOps CLI tools on container creation
- Provides isolated, reproducible development environment
Key files added:
.devcontainer/devcontainer.json.devcontainer/Dockerfile.devcontainer/post-create.sh
Usage:
yo @cbs-consulting/btp:devcontainerNote: This generator is automatically included when using the CAP generator.
☁️ Azure DevOps Setup Generator
Purpose: Create automation scripts for Azure DevOps branch policies and CI/CD pipelines.
What it does:
- Generates bash script to automate Azure DevOps configuration
- Creates
mainanddevelopmentbranches with policies - Configures code review requirements, merge strategies, and build validation
- Sets up Azure Pipeline from
azure-pipelines.yaml
Key files added:
scripts/setup-azure-devops/setup.sh(automation script)scripts/setup-azure-devops/azure-devops.env(configuration variables)scripts/setup-azure-devops/README.md(detailed documentation)
Usage:
yo @cbs-consulting/btp:setup-azure-devops
# Then run: bash scripts/setup-azure-devops/setup.shNote: This generator is automatically included when using the CAP generator with Azure DevOps enabled.
Generated Project Structure (CAP)
When using the CAP generator, your project will include:
my-cap-project/
├── .devcontainer/ # Dev container configuration
│ ├── devcontainer.json
│ ├── Dockerfile
│ └── post-create.sh
├── .vscode/ # VS Code settings & extensions
│ ├── settings.json
│ └── extensions.json
├── app/ # UI5 applications (from cds init)
├── db/ # Database models (from cds init)
├── srv/ # Service definitions (from cds init)
├── mta-ext/ # MTA extensions for environments
│ ├── dev.mtaext
│ ├── test.mtaext
│ └── prod.mtaext
├── scripts/ # Automation scripts
│ └── setup-azure-devops/ # Azure DevOps setup (if enabled)
│ ├── setup.sh
│ ├── azure-devops.env
│ └── README.md
├── .gitignore # Comprehensive ignore patterns
├── .gitconfig.aliases # Git workflow aliases
├── .gitattributes # Line ending configuration
├── .npmrc # npm settings
├── azure-pipelines.yaml # CI/CD pipeline (if enabled)
├── tsconfig.json # Project TypeScript config
├── eslint.config.mjs # ESLint configuration
├── prettier.config.mjs # Prettier configuration
├── mta.yaml # MTA deployment descriptor
└── package.json # Dependencies and scriptsAvailable Scripts
The CAP generator adds these npm scripts:
Code Quality:
npm run format- Format code with Prettiernpm run format:check- Check if code is properly formattednpm run lint- Run ESLintnpm run lint:fix- Fix auto-fixable ESLint issues
Testing & Building:
npm test- Run testsnpm run build- Build TypeScriptnpm run coverage-report- Generate test coverage report
Deployment:
npm run build:mta- Build MTA archivenpm run deploy-dev- Deploy to dev environment
Utilities:
npm run git-config- Set up git aliasesnpm run check-deps- Check for outdated dependenciesnpm run upgrade-deps- Upgrade dependencies (minor versions)
Git Hooks:
- Pre-commit hook automatically runs linting and formatting on staged files
Key Features
- ✅ TypeScript-first with strict compiler settings
- ✅ Code quality enforced via ESLint, Prettier, and pre-commit hooks
- ✅ Git workflows with advanced aliases for ticket-based development
- ✅ MTA deployment with environment-specific configurations
- ✅ Dev containers for reproducible development environments
- ✅ Azure DevOps automation for branch policies and CI/CD
- ✅ VS Code optimized with 30+ recommended extensions
- ✅ UI5 linting with @ui5/linter integration
- ✅ Centralized configs via @cbs-consulting/tools package
Development
To develop this generator locally:
git clone <repository-url>
cd generator-btp
npm install
npm link
yo @cbs-consulting/btpRun tests:
npm test
npm run test:watch
npm run test:coverageSee DEVELOPMENT.md for more details.
